From 723ce1192533ff9d93ddc130ba54b4e0b46e1713 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 12:20:17 +0000 Subject: [PATCH 001/147] Auto-generated commit 3d5cf2f597a349c35b81920055bfc1cbcdbedfad --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 362 +++++++ index.d.ts | 295 ++++++ index.mjs | 4 + index.mjs.map | 1 + package.json | 39 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3900 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..e856f8b --- /dev/null +++ b/README.md @@ -0,0 +1,362 @@ + + +# Debug Stream + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> [Transform stream][transform-stream] for [debugging][node-debug] stream pipelines. + + + +
+ +## Usage + +```javascript +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; +``` + + + +#### debugStream( \[options,] \[clbk] ) + +Creates a [transform stream][transform-stream] for [debugging][node-debug] stream pipelines. + +```javascript +import ENV from 'https://cdn.jsdelivr.net/gh/stdlib-js/process-env@esm/index.mjs'; + +// Set the `DEBUG` environment variable... +ENV.DEBUG = '*'; + +var stream = debugStream({ + 'name': 'my-stream' +}); + +stream.write( 'a' ); +stream.write( 'b' ); +stream.write( 'c' ); +stream.end(); +``` + +The function accepts the following `options`: + +- **name**: [debug][node-debug] namespace. +- **objectMode**: specifies whether a [stream][stream] should operate in [objectMode][object-mode]. Default: `false`. +- **highWaterMark**: specifies the `Buffer` level at which `write()` calls start returning `false`. +- **allowHalfOpen**: specifies whether a [stream][stream] should remain open even if one side ends. Default: `false`. +- **readableObjectMode**: specifies whether the readable side should be in [objectMode][object-mode]. Default: `false`. + +To set [stream][stream] `options`, + +```javascript +var opts = { + 'name': 'my-app', + 'objectMode': true, + 'highWaterMark': 64, + 'allowHalfOpen': true, + 'readableObjectMode': false // overridden by `objectMode` option when `objectMode=true` +}; + +var stream = debugStream( opts ); +``` + +By default, each `chunk` is logged as a JSON stringified `string`, along with the `chunk` index. For more control over logging behavior, provide a `callback`. + +```javascript +function logger( debug, chunk, idx ) { + debug( 'Received a new chunk...' ); + debug( 'Beep: %s', chunk.beep ); + debug( 'Boop: %s', chunk.boop ); +} + +var opts = { + 'name': 'my-pipeline' +}; + +var stream = debugStream( opts, logger ); +``` + +#### debugStream.factory( \[options] ) + +Returns a `function` for creating [streams][transform-stream] which are identically configured according to provided `options`. + +```javascript +var opts = { + 'objectMode': true, + 'highWaterMark': 64 +}; + +var factory = debugStream.factory( opts ); +``` + +This method accepts the same `options` as [`debugStream()`](#debug-stream), **except** for `name`, which must be provided **explicitly**. + +##### factory( name\[, clbk] ) + +Creates a [debug][node-debug] stream. + +```javascript +var factory = debugStream.factory(); + +var streams = []; +var i; + +// Assign each stream to a separate debug namespace... +for ( i = 0; i < 10; i++ ) { + streams.push( factory( 'stream '+i ) ); +} +``` + +#### debugStream.objectMode( \[options,] \[clbk] ) + +This method is a convenience function to create [streams][stream] which **always** operate in [objectMode][object-mode]. + +```javascript +var stream = debugStream.objectMode({ + 'name': 'beep-boop' +}); + +stream.write({ + 'value': 'a' +}); +stream.write({ + 'value': 'b' +}); +stream.write({ + 'value': 'c' +}); +stream.end(); +``` + +This method accepts the same `options` as [`debugStream()`](#debug-stream); however, the method will **always** override the [objectMode][object-mode] option in `options`. + +
+ + + +
+ +## Notes + +- If the [`DEBUG`][node-debug] environment variable is **not** set, no data is logged. +- Providing a `name` option is **strongly** encouraged, as the [`DEBUG`][node-debug] environment variable can be used to filter debuggers. + +
+ + + +
+ +## 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..81d6958 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,295 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 { Transform } from 'stream'; + +/** +* Interface defining stream options. +*/ +interface Options { + /** + * Debug namespace. + */ + name?: string; + + /** + * Specifies whether a stream should operate in object mode (default: `false`). + */ + objectMode?: boolean; + + /** + * Specifies the `Buffer` level for when `write()` starts returning `false`. + */ + highWaterMark?: number; + + /** + * Specifies whether the stream should remain open even if one side ends (default: `false`). + */ + allowHalfOpen?: boolean; + + /** + * Specifies whether the readable side should be in object mode (default: `false`). + */ + readableObjectMode?: boolean; +} + +/** +* Callback function invoked upon receiving data. +*/ +type Nullary = () => void; + +/** +* Callback function invoked upon receiving data. +* +* @param debug - logging function +* @param chunk - data chunk +*/ +type Unary = ( debug: Function ) => void; + +/** +* Callback function invoked upon receiving data. +* +* @param debug - logging function +* @param chunk - data chunk +* @param idx - chunk index +*/ +type Binary = ( debug: Function, chunk: any ) => void; + +/** +* Callback function invoked upon receiving data. +* +* @param debug - logging function +* @param chunk - data chunk +* @param idx - chunk index +*/ +type Ternary = ( debug: Function, chunk: any, idx: number ) => void; + +/** +* Callback function invoked upon receiving data. +* +* @param debug - logging function +* @param chunk - data chunk +* @param idx - chunk index +*/ +type Callback = Nullary | Unary | Binary | Ternary; + +/** +* Interface defining a stream constructor which is both "newable" and "callable". +*/ +interface Constructor { + /** + * Debug stream constructor. + * + * @param options - stream options + * @param options.name - debug namespace + * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) + * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` + * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) + * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) + * @param clbk - callback to invoke upon receiving data + * @returns debug stream + * + * @example + * var DebugStream = debugStream; + * var stream = new DebugStream({ + * 'name': 'my-stream' + * }); + * + * stream.write( 'a' ); + * stream.write( 'b' ); + * stream.write( 'c' ); + * stream.end(); + */ + new( options: Options, clbk?: Callback ): Transform; // newable + + /** + * Debug stream constructor. + * + * @param clbk - callback to invoke upon receiving data + * @returns debug stream + * + * @example + * var DebugStream = debugStream; + * var stream = new DebugStream(); + * + * stream.write( 'a' ); + * stream.write( 'b' ); + * stream.write( 'c' ); + * stream.end(); + */ + new( clbk?: Callback ): Transform; // newable + + /** + * Debug stream constructor. + * + * @param options - stream options + * @param options.name - debug namespace + * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) + * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` + * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) + * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) + * @param clbk - callback to invoke upon receiving data + * @returns debug stream + * + * @example + * var stream = debugStream({ + * 'name': 'my-stream' + * }); + * + * stream.write( 'a' ); + * stream.write( 'b' ); + * stream.write( 'c' ); + * stream.end(); + */ + ( options: Options, clbk?: Callback ): Transform; // callable + + /** + * Debug stream constructor. + * + * @param clbk - callback to invoke upon receiving data + * @returns debug stream + * + * @example + * var stream = debugStream(); + * + * stream.write( 'a' ); + * stream.write( 'b' ); + * stream.write( 'c' ); + * stream.end(); + */ + ( clbk?: Callback ): Transform; // callable + + /** + * Creates a reusable debug stream factory. + * + * @param options - stream options + * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) + * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` + * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) + * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) + * @returns debug stream factory + * + * @example + * var opts = { + * 'objectMode': true, + * 'highWaterMark': 64 + * }; + * + * var factory = debugStream.factory( opts ); + * + * // Assign each stream to a separate debug namespace... + * var streams = []; + * var i; + * for ( i = 0; i < 10; i++ ) { + * streams.push( factory( 'stream '+i ) ); + * } + */ + factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; + + /** + * Returns a debug stream with `objectMode` set to `true`. + * + * @param options - stream options + * @param options.name - debug namespace + * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` + * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) + * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) + * @param clbk - callback to invoke upon receiving data + * @throws must provide valid options + * @returns debug stream + * + * @example + * var stream = debugStream.objectMode({ + * 'name': 'my-stream' + * }); + * + * stream.write( {'value': 'a'} ); + * stream.write( {'value': 'b'} ); + * stream.write( {'value': 'c'} ); + * stream.end(); + */ + objectMode( options: Options, clbk?: Callback ): Transform; + + /** + * Returns a debug stream with `objectMode` set to `true`. + * + * @param clbk - callback to invoke upon receiving data + * @returns debug stream + * + * @example + * var stream = debugStream.objectMode(); + * + * stream.write( {'value': 'a'} ); + * stream.write( {'value': 'b'} ); + * stream.write( {'value': 'c'} ); + * stream.end(); + */ + objectMode( clbk?: Callback ): Transform; +} + +/** +* Returns a debug stream. +* +* @param options - stream options +* @throws must provide valid options +* @returns stream instance +* +* @example +* var DebugStream = debugStream; +* var stream = new DebugStream({ +* 'name': 'my-stream' +* }); +* +* stream.write( 'a' ); +* stream.write( 'b' ); +* stream.write( 'c' ); +* stream.end(); +* +* @example +* var opts = { +* 'objectMode': true, +* 'highWaterMark': 64 +* }; +* +* var factory = debugStream.factory( opts ); +* +* // Assign each stream to a separate debug namespace... +* var streams = []; +* var i; +* for ( i = 0; i < 10; i++ ) { +* streams.push( factory( 'stream '+i ) ); +* } +* +* @example +* var stream = debugStream.objectMode(); +* +* stream.write( {'value': 'a'} ); +* stream.write( {'value': 'b'} ); +* stream.write( {'value': 'c'} ); +* stream.end(); +*/ +declare var inspectStream: Constructor; + + +// EXPORTS // + +export = inspectStream; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1d5c4d0 --- /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/streams-node-inspect@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function c(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function p(){throw new Error("setTimeout has not been defined")}function h(){throw new Error("clearTimeout has not been defined")}var b=p,g=h;function w(e){if(b===setTimeout)return setTimeout(e,0);if((b===p||!b)&&setTimeout)return b=setTimeout,setTimeout(e,0);try{return b(e,0)}catch(t){try{return b.call(null,e,0)}catch(t){return b.call(this,e,0)}}}"function"==typeof f.setTimeout&&(b=setTimeout),"function"==typeof f.clearTimeout&&(g=clearTimeout);var j,v=[],y=!1,O=-1;function T(){y&&j&&(y=!1,j.length?v=j.concat(v):O=-1,v.length&&M())}function M(){if(!y){var e=w(T);y=!0;for(var t=v.length;t;){for(j=v,v=[];++O1)for(var n=1;n1?new ne(e,t):1===arguments.length?new ne(e):new ne;if(n=Y($),arguments.length>1){if(!Q(t))throw new TypeError(X("invalid argument. Callback argument must be a function. Value: `%s`.",t));s=t,i=ee(n,e)}else arguments.length&&(Q(e)?s=e:i=ee(n,e));if(i)throw i;return r=n.name?"debug-stream:"+n.name:"debug-stream",o=te(r),Z("Creating a transform stream configured with the following options: %s.",JSON.stringify(n)),K.call(this,n,a),this;function a(e,t){if(s)return Z("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),s(o,e,t);U(e)&&(e=e.toString()),e=JSON.stringify(e),Z("Received a new chunk. Chunk: %s. Index: %d.",e,t),o("Chunk: %s. Index: %d.",e,t)}}s(ne,K);var re=n,oe=a,ie=o,se=i,ae=ne;var le=a,ue=o,de=i,me=ne;var ce=function(e){var t;if(arguments.length){if(!le(e))throw new TypeError(ue("invalid argument. Options argument must be an object. Value: `%s`.",e));t=de(e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new me(t,n):new me(t)}},fe=e,pe=ne,he=function(e,t){var n,r;if(arguments.length>1){if(!oe(e))throw new TypeError(ie("invalid argument. Options argument must be an object. Value: `%s`.",e));if(n=se(e),r=t,!re(t))throw new TypeError(ie("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(re(e))n={},r=e;else{if(!oe(e))throw new TypeError(ie("invalid argument. Options argument must be an object. Value: `%s`.",e));n=se(e)}else n={};return n.objectMode=!0,void 0===r?new ae(n):new ae(n,r)},be=ce;fe(pe,"objectMode",he),fe(pe,"factory",be);var ge=pe;export{ge as default,be as factory,he as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2490d31 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../node_modules/debug/src/index.js","../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/main.js","../lib/logger.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["/**\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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar copy = require( '@stdlib/utils-copy' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar debug = require( 'debug' );\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 isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar copy = require( '@stdlib/utils-copy' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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 = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy = require( '@stdlib/utils-copy' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["module","exports","process","type","require","debug_1","require$$0","isObject","hasOwnProp","require$$1","isBoolean","require$$2","isPrimitive","isNonNegative","require$$3","isString","require$$4","format","require$$5","InspectStream","isFunction","isBuffer","copy","debug","require$$6","DEFAULTS","require$$7","validate","opts","options","name","TypeError","objectMode","readableObjectMode","allowHalfOpen","highWaterMark","logger","DebugStream","clbk","log","err","cb","this","arguments","length","NAMESPACE","JSON","stringify","call","inspect","chunk","idx","toString","Stream","factory","debugStream","setReadOnly","stream","lib"],"mappings":";;ouGAMEA,OAAOC,aADc,IAAZC,GAA4C,aAAjBA,EAAQC,KAC3BC,QAAQ,gBAERA,QAAQ,sDCyB3BC,EAXaC,ECAI,iFCAbC,EAAWD,EACXE,EAAaC,EACbC,EAAYC,EAAuCC,YACnDC,EAAgBC,EAAkDF,YAClEG,EAAWC,EAAsCJ,YACjDK,EAASC,EA0Db,IC/DIC,EAAgBb,EAChBc,EAAaX,EACbY,EAAWV,EACXM,EAASH,EACTQ,EAAON,EAEPO,EAAQC,EACRC,EAAWC,EAEXC,GDcJ,SAAmBC,EAAMC,GACxB,OAAMtB,EAAUsB,GAGXrB,EAAYqB,EAAS,UACzBD,EAAKE,KAAOD,EAAQC,MACdf,EAAUa,EAAKE,OACb,IAAIC,UAAWd,EAAQ,8DAA+D,OAAQW,EAAKE,OAGvGtB,EAAYqB,EAAS,gBACzBD,EAAKI,WAAaH,EAAQG,YACpBtB,EAAWkB,EAAKI,aACd,IAAID,UAAWd,EAAQ,+DAAgE,aAAcW,EAAKI,aAG9GxB,EAAYqB,EAAS,wBACzBD,EAAKK,mBAAqBJ,EAAQI,oBAC5BvB,EAAWkB,EAAKK,qBACd,IAAIF,UAAWd,EAAQ,+DAAgE,qBAAsBW,EAAKK,qBAGtHzB,EAAYqB,EAAS,mBACzBD,EAAKM,cAAgBL,EAAQK,eACvBxB,EAAWkB,EAAKM,gBACd,IAAIH,UAAWd,EAAQ,+DAAgE,gBAAiBW,EAAKM,gBAGjH1B,EAAYqB,EAAS,mBACzBD,EAAKO,cAAgBN,EAAQM,eACvBtB,EAAee,EAAKO,gBAClB,IAAIJ,UAAWd,EAAQ,0EAA2E,gBAAiBW,EAAKO,gBAG1H,KAhCC,IAAIJ,UAAWd,EAAQ,qEAAsEY,KCflGO,GCVQ9B,EDwCZ,SAAS+B,GAAaR,EAASS,GAC9B,IAAIV,EACAE,EACAS,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,IACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,GAAaR,EAASS,GAER,IAArBK,UAAUC,OACP,IAAIP,GAAaR,GAElB,IAAIQ,GAGZ,GADAT,EAAON,EAAMG,GACRkB,UAAUC,OAAS,EAAI,CAC3B,IAAMxB,EAAYkB,GACjB,MAAM,IAAIP,UAAWd,EAAQ,uEAAwEqB,IAEtGG,EAAKH,EACLE,EAAMb,GAAUC,EAAMC,QACXc,UAAUC,SAChBxB,EAAYS,GAChBY,EAAKZ,EAELW,EAAMb,GAAUC,EAAMC,IAGxB,GAAKW,EACJ,MAAMA,EAYP,OATCV,EADIF,EAAKE,KACFe,gBAAkBjB,EAAKE,KFzEf,eE6EhBS,EAAMH,GAAQN,GAEdP,EAAO,yEAA0EuB,KAAKC,UAAWnB,IACjGT,EAAc6B,KAAMN,KAAMd,EAAMqB,GAEzBP,KAUP,SAASO,EAASC,EAAOC,GACxB,GAAKV,EAEJ,OADAlB,EAAO,8CAA+C2B,EAAME,WAAYD,GACjEV,EAAIF,EAAKW,EAAOC,GAEnB9B,EAAU6B,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxB3B,EAAO,8CAA+C2B,EAAOC,GAC7DZ,EAAK,wBAAyBW,EAAOC,IAjGzBjC,EAwGLmB,GAAalB,GAKtB,IElHIC,GAAad,EACbC,GAAWE,EACXQ,GAASN,EACTW,GAAOR,EACPuC,GF8GahB,GE9CjB,ICpEI9B,GAAWD,EACXW,GAASR,EACTa,GAAOX,EACP0C,GH+GahB,GG9CjB,IAAAiB,GAlCA,SAAwBzB,GACvB,IAAID,EACJ,GAAKe,UAAUC,OAAS,CACvB,IAAMrC,GAAUsB,GACf,MAAM,IAAIE,UAAWd,GAAQ,qEAAsEY,IAEpGD,EAAON,GAAMO,QAEbD,EAAO,GAER,OAAO2B,EAYP,SAASA,EAAazB,EAAMQ,GAE3B,OADAV,EAAKE,KAAOA,EACPa,UAAUC,OAAS,EAChB,IAAIS,GAAQzB,EAAMU,GAEnB,IAAIe,GAAQzB,KCbrB4B,GAAAlD,EACAmD,GJiEiBpB,GIhEjBL,GFjBA,SAAqBH,EAASS,GAC7B,IAAIV,EACAa,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMrC,GAAUsB,GACf,MAAM,IAAIE,UAAWd,GAAQ,qEAAsEY,IAIpG,GAFAD,EAAON,GAAMO,GACbY,EAAKH,GACClB,GAAYkB,GACjB,MAAM,IAAIP,UAAWd,GAAQ,uEAAwEqB,SAEhG,GAAKK,UAAUC,OACrB,GAAKxB,GAAYS,GAChBD,EAAO,GACPa,EAAKZ,MACC,CACN,IAAMtB,GAAUsB,GACf,MAAM,IAAIE,UAAWd,GAAQ,qEAAsEY,IAEpGD,EAAON,GAAMO,QAGdD,EAAO,GAGR,OADAA,EAAKI,YAAa,OACN,IAAPS,EACG,IAAIY,GAAQzB,GAEb,IAAIyB,GAAQzB,EAAMa,IEX1Ba,GAAAxC,GAKA0C,GAAAC,GAAA,aAAAzB,IACAwB,GAAAC,GAAA,UAAAH,IAKA,IAAAI,GAAAD"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..6a0dbc1 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "@stdlib/streams-node-debug", + "version": "0.0.0", + "description": "Transform stream for debugging stream pipelines.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/streams-node-debug.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "utilities", + "utility", + "utils", + "util", + "stream", + "streams", + "writable", + "readable", + "transform", + "inspect", + "debug", + "log", + "monitor", + "tap", + "spy", + "sniff" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..31b3ed7 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From d1de599fb64569500de4fa2766cc09fdc1e852c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 00:28:07 +0000 Subject: [PATCH 002/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From ca37c1710f0f2569c2ead559497421a0e43f9da3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 12:06:20 +0000 Subject: [PATCH 003/147] Remove files --- index.d.ts | 295 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2989 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1d5c4d0..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/streams-node-inspect@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-copy@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function c(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function p(){throw new Error("setTimeout has not been defined")}function h(){throw new Error("clearTimeout has not been defined")}var b=p,g=h;function w(e){if(b===setTimeout)return setTimeout(e,0);if((b===p||!b)&&setTimeout)return b=setTimeout,setTimeout(e,0);try{return b(e,0)}catch(t){try{return b.call(null,e,0)}catch(t){return b.call(this,e,0)}}}"function"==typeof f.setTimeout&&(b=setTimeout),"function"==typeof f.clearTimeout&&(g=clearTimeout);var j,v=[],y=!1,O=-1;function T(){y&&j&&(y=!1,j.length?v=j.concat(v):O=-1,v.length&&M())}function M(){if(!y){var e=w(T);y=!0;for(var t=v.length;t;){for(j=v,v=[];++O1)for(var n=1;n1?new ne(e,t):1===arguments.length?new ne(e):new ne;if(n=Y($),arguments.length>1){if(!Q(t))throw new TypeError(X("invalid argument. Callback argument must be a function. Value: `%s`.",t));s=t,i=ee(n,e)}else arguments.length&&(Q(e)?s=e:i=ee(n,e));if(i)throw i;return r=n.name?"debug-stream:"+n.name:"debug-stream",o=te(r),Z("Creating a transform stream configured with the following options: %s.",JSON.stringify(n)),K.call(this,n,a),this;function a(e,t){if(s)return Z("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),s(o,e,t);U(e)&&(e=e.toString()),e=JSON.stringify(e),Z("Received a new chunk. Chunk: %s. Index: %d.",e,t),o("Chunk: %s. Index: %d.",e,t)}}s(ne,K);var re=n,oe=a,ie=o,se=i,ae=ne;var le=a,ue=o,de=i,me=ne;var ce=function(e){var t;if(arguments.length){if(!le(e))throw new TypeError(ue("invalid argument. Options argument must be an object. Value: `%s`.",e));t=de(e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new me(t,n):new me(t)}},fe=e,pe=ne,he=function(e,t){var n,r;if(arguments.length>1){if(!oe(e))throw new TypeError(ie("invalid argument. Options argument must be an object. Value: `%s`.",e));if(n=se(e),r=t,!re(t))throw new TypeError(ie("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(re(e))n={},r=e;else{if(!oe(e))throw new TypeError(ie("invalid argument. Options argument must be an object. Value: `%s`.",e));n=se(e)}else n={};return n.objectMode=!0,void 0===r?new ae(n):new ae(n,r)},be=ce;fe(pe,"objectMode",he),fe(pe,"factory",be);var ge=pe;export{ge as default,be as factory,he as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2490d31..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../node_modules/debug/src/index.js","../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/main.js","../lib/logger.js","../lib/object_mode.js","../lib/factory.js","../lib/index.js"],"sourcesContent":["/**\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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar copy = require( '@stdlib/utils-copy' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar debug = require( 'debug' );\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 isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar copy = require( '@stdlib/utils-copy' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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 = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy = require( '@stdlib/utils-copy' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["module","exports","process","type","require","debug_1","require$$0","isObject","hasOwnProp","require$$1","isBoolean","require$$2","isPrimitive","isNonNegative","require$$3","isString","require$$4","format","require$$5","InspectStream","isFunction","isBuffer","copy","debug","require$$6","DEFAULTS","require$$7","validate","opts","options","name","TypeError","objectMode","readableObjectMode","allowHalfOpen","highWaterMark","logger","DebugStream","clbk","log","err","cb","this","arguments","length","NAMESPACE","JSON","stringify","call","inspect","chunk","idx","toString","Stream","factory","debugStream","setReadOnly","stream","lib"],"mappings":";;ouGAMEA,OAAOC,aADc,IAAZC,GAA4C,aAAjBA,EAAQC,KAC3BC,QAAQ,gBAERA,QAAQ,sDCyB3BC,EAXaC,ECAI,iFCAbC,EAAWD,EACXE,EAAaC,EACbC,EAAYC,EAAuCC,YACnDC,EAAgBC,EAAkDF,YAClEG,EAAWC,EAAsCJ,YACjDK,EAASC,EA0Db,IC/DIC,EAAgBb,EAChBc,EAAaX,EACbY,EAAWV,EACXM,EAASH,EACTQ,EAAON,EAEPO,EAAQC,EACRC,EAAWC,EAEXC,GDcJ,SAAmBC,EAAMC,GACxB,OAAMtB,EAAUsB,GAGXrB,EAAYqB,EAAS,UACzBD,EAAKE,KAAOD,EAAQC,MACdf,EAAUa,EAAKE,OACb,IAAIC,UAAWd,EAAQ,8DAA+D,OAAQW,EAAKE,OAGvGtB,EAAYqB,EAAS,gBACzBD,EAAKI,WAAaH,EAAQG,YACpBtB,EAAWkB,EAAKI,aACd,IAAID,UAAWd,EAAQ,+DAAgE,aAAcW,EAAKI,aAG9GxB,EAAYqB,EAAS,wBACzBD,EAAKK,mBAAqBJ,EAAQI,oBAC5BvB,EAAWkB,EAAKK,qBACd,IAAIF,UAAWd,EAAQ,+DAAgE,qBAAsBW,EAAKK,qBAGtHzB,EAAYqB,EAAS,mBACzBD,EAAKM,cAAgBL,EAAQK,eACvBxB,EAAWkB,EAAKM,gBACd,IAAIH,UAAWd,EAAQ,+DAAgE,gBAAiBW,EAAKM,gBAGjH1B,EAAYqB,EAAS,mBACzBD,EAAKO,cAAgBN,EAAQM,eACvBtB,EAAee,EAAKO,gBAClB,IAAIJ,UAAWd,EAAQ,0EAA2E,gBAAiBW,EAAKO,gBAG1H,KAhCC,IAAIJ,UAAWd,EAAQ,qEAAsEY,KCflGO,GCVQ9B,EDwCZ,SAAS+B,GAAaR,EAASS,GAC9B,IAAIV,EACAE,EACAS,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,IACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,GAAaR,EAASS,GAER,IAArBK,UAAUC,OACP,IAAIP,GAAaR,GAElB,IAAIQ,GAGZ,GADAT,EAAON,EAAMG,GACRkB,UAAUC,OAAS,EAAI,CAC3B,IAAMxB,EAAYkB,GACjB,MAAM,IAAIP,UAAWd,EAAQ,uEAAwEqB,IAEtGG,EAAKH,EACLE,EAAMb,GAAUC,EAAMC,QACXc,UAAUC,SAChBxB,EAAYS,GAChBY,EAAKZ,EAELW,EAAMb,GAAUC,EAAMC,IAGxB,GAAKW,EACJ,MAAMA,EAYP,OATCV,EADIF,EAAKE,KACFe,gBAAkBjB,EAAKE,KFzEf,eE6EhBS,EAAMH,GAAQN,GAEdP,EAAO,yEAA0EuB,KAAKC,UAAWnB,IACjGT,EAAc6B,KAAMN,KAAMd,EAAMqB,GAEzBP,KAUP,SAASO,EAASC,EAAOC,GACxB,GAAKV,EAEJ,OADAlB,EAAO,8CAA+C2B,EAAME,WAAYD,GACjEV,EAAIF,EAAKW,EAAOC,GAEnB9B,EAAU6B,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxB3B,EAAO,8CAA+C2B,EAAOC,GAC7DZ,EAAK,wBAAyBW,EAAOC,IAjGzBjC,EAwGLmB,GAAalB,GAKtB,IElHIC,GAAad,EACbC,GAAWE,EACXQ,GAASN,EACTW,GAAOR,EACPuC,GF8GahB,GE9CjB,ICpEI9B,GAAWD,EACXW,GAASR,EACTa,GAAOX,EACP0C,GH+GahB,GG9CjB,IAAAiB,GAlCA,SAAwBzB,GACvB,IAAID,EACJ,GAAKe,UAAUC,OAAS,CACvB,IAAMrC,GAAUsB,GACf,MAAM,IAAIE,UAAWd,GAAQ,qEAAsEY,IAEpGD,EAAON,GAAMO,QAEbD,EAAO,GAER,OAAO2B,EAYP,SAASA,EAAazB,EAAMQ,GAE3B,OADAV,EAAKE,KAAOA,EACPa,UAAUC,OAAS,EAChB,IAAIS,GAAQzB,EAAMU,GAEnB,IAAIe,GAAQzB,KCbrB4B,GAAAlD,EACAmD,GJiEiBpB,GIhEjBL,GFjBA,SAAqBH,EAASS,GAC7B,IAAIV,EACAa,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMrC,GAAUsB,GACf,MAAM,IAAIE,UAAWd,GAAQ,qEAAsEY,IAIpG,GAFAD,EAAON,GAAMO,GACbY,EAAKH,GACClB,GAAYkB,GACjB,MAAM,IAAIP,UAAWd,GAAQ,uEAAwEqB,SAEhG,GAAKK,UAAUC,OACrB,GAAKxB,GAAYS,GAChBD,EAAO,GACPa,EAAKZ,MACC,CACN,IAAMtB,GAAUsB,GACf,MAAM,IAAIE,UAAWd,GAAQ,qEAAsEY,IAEpGD,EAAON,GAAMO,QAGdD,EAAO,GAGR,OADAA,EAAKI,YAAa,OACN,IAAPS,EACG,IAAIY,GAAQzB,GAEb,IAAIyB,GAAQzB,EAAMa,IEX1Ba,GAAAxC,GAKA0C,GAAAC,GAAA,aAAAzB,IACAwB,GAAAC,GAAA,UAAAH,IAKA,IAAAI,GAAAD"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 31b3ed7..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f2bc985d9e43d8b66e27977990c9a889ed66c23d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 12:06:56 +0000 Subject: [PATCH 004/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 -- examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 -- lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 146 -- test/test.js | 43 - test/test.main.js | 339 --- test/test.object_mode.js | 184 -- test/test.validate.js | 219 -- 48 files changed, 2721 insertions(+), 5109 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 d154fc2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:07:40.181Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dadbe2f --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..701818b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;2lCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c31a73..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..604a260 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 1fc13b4a480a645b738b1a4d7ae955a6ff49f3bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 20:03:52 +0000 Subject: [PATCH 005/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From f2f08041cfaf1cbb9b7ed79bfbc55390d15ef67f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 08:06:15 +0000 Subject: [PATCH 006/147] Remove files --- index.d.ts | 295 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2989 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dadbe2f..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 701818b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;2lCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 604a260..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0a7de3d58ebc2108d1855b57d947b94daddfb301 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 08:06:50 +0000 Subject: [PATCH 007/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 -- examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 -- lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 146 -- test/test.js | 43 - test/test.main.js | 339 --- test/test.object_mode.js | 184 -- test/test.validate.js | 219 -- 48 files changed, 2721 insertions(+), 5109 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 97029ce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:11:48.841Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dadbe2f --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..701818b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;2lCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c31a73..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7d3c373 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 8bd48b85ec811d5242af1c38f3e03adb295542ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:41:44 +0000 Subject: [PATCH 008/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From 4b32b6d9206bdace08ccf2c8a8d33f6f1d5dca4a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:29:04 +0000 Subject: [PATCH 009/147] Remove files --- index.d.ts | 295 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2989 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dadbe2f..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 701818b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;2lCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7d3c373..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 2979669428c3ae2f974256c8e7f443f6e7447b9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:29:49 +0000 Subject: [PATCH 010/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 -- examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 -- lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 146 -- test/test.js | 43 - test/test.main.js | 339 --- test/test.object_mode.js | 184 -- test/test.validate.js | 219 -- 48 files changed, 2721 insertions(+), 5148 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 e6035c2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:14:58.438Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7ed664c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d40b80b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c31a73..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..bf79645 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 1950275225b7b48941e2e10ce82d9f35a7a35838 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:32:43 +0000 Subject: [PATCH 011/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From f16f9da4fc80e67d6712fc2d1e43e526ae704d89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 13:37:24 +0000 Subject: [PATCH 012/147] Remove files --- index.d.ts | 295 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2989 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7ed664c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d40b80b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bf79645..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 21c4fc182a94015b2492bb78aed8d0ef04f5ba9d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 13:38:08 +0000 Subject: [PATCH 013/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 -- examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 -- lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 146 -- test/test.js | 43 - test/test.main.js | 339 --- test/test.object_mode.js | 184 -- test/test.validate.js | 219 -- 48 files changed, 2721 insertions(+), 5164 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 d308c63..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:12:54.924Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7ed664c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d40b80b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3c31a73..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..32e2788 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 85a7ef5b9c6fade8b7d4fa33966abedb04b44e1f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 01:38:34 +0000 Subject: [PATCH 014/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From 7f9b3e910c69d3c3e9131436070318133ec3c07b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 15:15:26 +0000 Subject: [PATCH 015/147] Remove files --- index.d.ts | 295 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2989 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7ed664c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d40b80b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["debug","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","stream","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 32e2788..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 82cc539ca91fa387c6ad1f9de2923d042d7ce294 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 15:16:03 +0000 Subject: [PATCH 016/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 -- examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 -- lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.factory.js | 146 -- test/test.js | 43 - test/test.main.js | 339 --- test/test.object_mode.js | 184 -- test/test.validate.js | 219 -- 48 files changed, 2721 insertions(+), 5164 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 e08f4b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:37:54.176Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7ed664c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..354c959 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ceaff31 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 937e6eb27e32fa3c2bbbab543bc581b3d884c6be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:44:36 +0000 Subject: [PATCH 017/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From b2f0af83d25f6a1001cef7d2417b9d3c3f62464f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 17:39:02 +0000 Subject: [PATCH 018/147] Remove files --- index.d.ts | 295 ------ index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2989 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7ed664c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 354c959..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,ICezC,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,QACXmB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,ICrEvC,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,SAEjC,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,GACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAGdD,EAAO,GAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,GC5B1B,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,QAEbD,EAAO,GAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,IFgDrBqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ceaff31..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 2620b8c3a1d96cb8e35bef51eaea56603e331eac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 17:40:05 +0000 Subject: [PATCH 019/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 -- 48 files changed, 4076 insertions(+), 5164 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 72fef46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:26:04.004Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7ed664c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9c92b1f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CClBA,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,EACrC,CACF,CCvEA,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,EACnB,CACF,CF8CAqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e76c7a8 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 03c1a18ab68db1f19743ef89449d68f528e6e8fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 22:04:20 +0000 Subject: [PATCH 020/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 97f67f8..d0b1c55 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From 47fc072d3c160a88bed0d0a07c8fa97d7178511d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 13:32:41 +0000 Subject: [PATCH 021/147] Remove files --- index.d.ts | 295 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4344 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7ed664c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";var f=()=>{},j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function p(e,t){return d(t)?a(t,"name")&&(e.name=t.name,!h(e.name))?new TypeError(s("0fw2i","name",e.name)):a(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):a(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):a(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):a(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}function w(e,o){var d,a,l,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(d=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,l=p(d,e)}else arguments.length&&(r(e)?m=e:l=p(d,e));if(l)throw l;return d.name&&d.name,a=()=>{},f("Creating a transform stream configured with the following options: %s.",JSON.stringify(d)),t.call(this,d,h),this;function h(e,t){if(m)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(a,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),a("Chunk: %s. Index: %d.",e,t)}}function c(e,t){var n,o;if(arguments.length>1){if(!d(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!d(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function b(e){var t;if(arguments.length){if(!d(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",c),e(w,"factory",b);export{w as default,b as factory,c as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9c92b1f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/validate.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 logger from 'debug' ;\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;kmCA4BIA,0ECiBJ,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CClBA,SAASa,EAAab,EAASc,GAC9B,IAAIf,EAEAgB,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OAVKjB,EAAKI,MACgBJ,EAAKI,KAI/BY,SAEAlB,EAAO,yEAA0E2B,KAAKC,UAAW1B,IACjG2B,EAAcC,KAAMT,KAAMnB,EAAM6B,GAEzBV,KAUP,SAASU,EAASC,EAAOC,GACxB,GAAKb,EAEJ,OADApB,EAAO,8CAA+CgC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GAExBd,EAAK,wBAAyBc,EAAOC,EACrC,CACF,CCvEA,SAASvB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOoC,EAYP,SAASA,EAAahC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIa,EAAQlC,EAAMe,GAEnB,IAAImB,EAAQlC,EACnB,CACF,CF8CAqC,EAASvB,EAAaa,GGrDtBW,EAAAC,EAAA,aAAA/B,GACA8B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e76c7a8..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 504e97eb972ec993576c61aae104789760b6391e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 13:33:31 +0000 Subject: [PATCH 022/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 -- 48 files changed, 4076 insertions(+), 5185 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 72ac495..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:03:39.973Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..df2cf2f --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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 p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var w=p;function u(e,o){var a,d,l,f,m;if(!(this instanceof u))return arguments.length>1?new u(e,o):1===arguments.length?new u(e):new u;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=w(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new u(n):new u(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new u(t,r):new u(t)}}o(u,t),e(u,"objectMode",g),e(u,"factory",v);export{u as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..21d2b7e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;+/CA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d0b1c55..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c1305fb --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 397bfec4c102e49847750c8fc8ab85838d4973e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:03:18 +0000 Subject: [PATCH 023/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 68489ad..0163f44 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From ea0a48cbf9cf6891a08d3fa742af95df1f1b176c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 20:38:13 +0000 Subject: [PATCH 024/147] Remove files --- index.d.ts | 295 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4344 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index df2cf2f..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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 p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var w=p;function u(e,o){var a,d,l,f,m;if(!(this instanceof u))return arguments.length>1?new u(e,o):1===arguments.length?new u(e):new u;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=w(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new u(n):new u(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new u(t,r):new u(t)}}o(u,t),e(u,"objectMode",g),e(u,"factory",v);export{u as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 21d2b7e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js' ;\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport hasOwnProp from '@stdlib/assert-has-own-property' ;\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean' ;\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number' ;\nimport { isPrimitive as isString } from '@stdlib/assert-is-string' ;\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect' ;\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isBuffer from '@stdlib/assert-is-buffer' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport inherit from '@stdlib/utils-inherit' ;\nimport debug from './debug.js' ;\nimport DEFAULTS from './defaults.json' ;\nimport NAMESPACE from './namespace.js' ;\nimport validate from './validate.js' ;\nimport logger from './logger.js' ;\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function' ;\nimport isObject from '@stdlib/assert-is-plain-object' ;\nimport format from '@stdlib/error-tools-fmtprodmsg' ;\nimport copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy' ;\nimport Stream from './main.js' ;\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug' ;\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;+/CA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c1305fb..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b9882d0c8b4c59cd7d422ce585516b07fa32df4b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 20:38:55 +0000 Subject: [PATCH 025/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 -- 48 files changed, 4076 insertions(+), 5190 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 742f32a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:53:11.157Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..df2cf2f --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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 p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var w=p;function u(e,o){var a,d,l,f,m;if(!(this instanceof u))return arguments.length>1?new u(e,o):1===arguments.length?new u(e):new u;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=w(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new u(n):new u(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new u(t,r):new u(t)}}o(u,t),e(u,"objectMode",g),e(u,"factory",v);export{u as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d7e68f0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;+/CA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 0163f44..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..352012c --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 2d0d24f6d281e3817c3a4e8df7f8d1c6e9c13599 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:12:14 +0000 Subject: [PATCH 026/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 1a3ee0e..9eb5cb0 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From f7906262ba37fc54ff0fac62fbc7e74f2e66fa24 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 07:58:18 +0000 Subject: [PATCH 027/147] Remove files --- index.d.ts | 295 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4344 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index df2cf2f..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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 p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var w=p;function u(e,o){var a,d,l,f,m;if(!(this instanceof u))return arguments.length>1?new u(e,o):1===arguments.length?new u(e):new u;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=w(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new u(n):new u(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new u(t,r):new u(t)}}o(u,t),e(u,"objectMode",g),e(u,"factory",v);export{u as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d7e68f0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;+/CA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 352012c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ec7001bac82a68d7e2fbd4a613961af464b1b3ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 07:59:10 +0000 Subject: [PATCH 028/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 -- branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 -- 48 files changed, 4076 insertions(+), 5201 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 3fb8488..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:16:26.932Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5f93869 --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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 p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var w=p;function u(e,o){var a,d,l,f,m;if(!(this instanceof u))return arguments.length>1?new u(e,o):1===arguments.length?new u(e):new u;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=w(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new u(n):new u(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new u(t,r):new u(t)}}o(u,t),e(u,"objectMode",g),e(u,"factory",v);export{u as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d7e68f0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;+/CA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9eb5cb0..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..aebf731 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 90d111b77f98a275dca23838209db43774c52c30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:51:57 +0000 Subject: [PATCH 029/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 1a3ee0e..9eb5cb0 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.x", "@stdlib/assert-is-string": "^0.0.x", "@stdlib/streams-node-inspect": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/utils-copy": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", "@stdlib/utils-inherit": "^0.0.x", From 3b65d270fb707a7ca43eadde88cbfc22e1209198 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 15:06:44 +0000 Subject: [PATCH 030/147] Remove files --- index.d.ts | 295 ---- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4344 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5f93869..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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 p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var w=p;function u(e,o){var a,d,l,f,m;if(!(this instanceof u))return arguments.length>1?new u(e,o):1===arguments.length?new u(e):new u;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=w(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new u(n):new u(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new u(t,r):new u(t)}}o(u,t),e(u,"objectMode",g),e(u,"factory",v);export{u as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d7e68f0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;+/CA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index aebf731..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 5c865a06785e0ecdd06eb19bf233d6b17f49c93f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 15:07:23 +0000 Subject: [PATCH 031/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5201 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 c302135..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:41:05.488Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 225bfde..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/debug" -click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba0520c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc578d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9eb5cb0..ad9f32b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/streams-node-inspect": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-inherit": "^0.0.x", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-string": "^0.0.x", - "@stdlib/streams-node-stdout": "^0.0.x", - "@stdlib/streams-node-transform": "^0.0.x", - "@stdlib/utils-next-tick": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "@stdlib/utils-parse-json": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3094784 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 76c9604a61958301412e9ff43fa6a04932d04ce2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 06:32:31 +0000 Subject: [PATCH 032/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 144de64..3521310 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.7", "@stdlib/assert-is-string": "^0.0.8", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", From 37198bc07ca504e75375e39369c0ab8addd418bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 15:38:34 +0000 Subject: [PATCH 033/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba0520c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc578d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3094784..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 171a310a0ecb1067042610cd23e452a90759b11d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 15:39:15 +0000 Subject: [PATCH 034/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5336 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 5886175..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T04:12:34.376Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba0520c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc578d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 3521310..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..27a525b --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 d0eb59022f2d782cf19afedca03b5a962aefb8d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 07:05:48 +0000 Subject: [PATCH 035/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 144de64..3521310 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.7", "@stdlib/assert-is-string": "^0.0.8", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", From 5c89870435ae21397e9958e1911ae4de7f1f2985 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 14:35:25 +0000 Subject: [PATCH 036/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba0520c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc578d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 27a525b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e1d76b18e3f41b4237df796fd990e9a8c5c9edf5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 14:36:19 +0000 Subject: [PATCH 037/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5342 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 1658202..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T04:49:42.499Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba0520c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc578d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 3521310..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6328c57 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 5bc7991b10ac42b5c4cdf3614b9071c584779822 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 06:49:59 +0000 Subject: [PATCH 038/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 144de64..3521310 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.7", "@stdlib/assert-is-string": "^0.0.8", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", From d5a0278598c5b5b0deaf403ee2b4bdcf089fba30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 14:15:30 +0000 Subject: [PATCH 039/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba0520c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc578d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6328c57..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 519cf82cd31868ac02176edd1d9f3463c8346621 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 14:16:26 +0000 Subject: [PATCH 040/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5342 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 524b173..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T04:33:53.436Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba0520c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc578d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 3521310..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5168052 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 bf5cd02acc11b21ff0613530dcef498c4219f87c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 06:31:08 +0000 Subject: [PATCH 041/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 144de64..3521310 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.7", "@stdlib/assert-is-string": "^0.0.8", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", From 8efa3a8d5a7e4bc9712950cc30f7e13a274ce223 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 14:34:11 +0000 Subject: [PATCH 042/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba0520c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc578d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5168052..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 62e3eb712e1690b2244e1032115e9f41a3283453 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 14:34:55 +0000 Subject: [PATCH 043/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5342 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 c428c39..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T04:11:53.172Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba0520c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc578d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 3521310..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..12efc06 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 716744a65c0d95900766ae53f915fe4723d7e9a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 06:32:17 +0000 Subject: [PATCH 044/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index 27e5f36..8d923cd 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 copy = require( '@stdlib/utils-copy' ); var Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = copy( options ); } else { diff --git a/lib/main.js b/lib/main.js index fe36bf0..698e719 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var copy = require( '@stdlib/utils-copy' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = copy( DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index fc8f010..734f21b 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = copy( options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 144de64..3521310 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@stdlib/assert-is-plain-object": "^0.0.7", "@stdlib/assert-is-string": "^0.0.8", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-copy": "^0.0.7", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", From 2b9d89931a16ac691546cfa8b7f4a8749fcc6eda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 14:48:34 +0000 Subject: [PATCH 045/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba0520c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc578d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 12efc06..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 97ed4c2f031307cfa6b9e0b6a8d750c7196f67a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 14:49:25 +0000 Subject: [PATCH 046/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5342 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 b27bcb5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T04:11:36.092Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba0520c --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fc578d0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 8d923cd..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 698e719..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = copy( DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 734f21b..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var copy = require( '@stdlib/utils-copy' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = copy( options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 3521310..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-copy": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b9be0e5 --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 9df23b09b452b878d74a0eec05bb3b42d729877d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:40:25 +0000 Subject: [PATCH 047/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..16d5ec3 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..a547655 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..24c6cb7 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 36ddf29..df4fcda 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/object-assign": "github:stdlib-js/object-assign#main", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", "debug": "^2.6.9" From 95811447d1896c9456d82375bc0ba4712414bd31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:40:48 +0000 Subject: [PATCH 048/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba0520c..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var b=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i(j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=b(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i(e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i(e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i(e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fc578d0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = copy( DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = copy( options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 copy from '@stdlib/utils-copy';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = copy( options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","copy","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;moDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAMC,GACRH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAMrB,GACbiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACb,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAMrB,EACf,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b9be0e5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From acb2f6b520b6096e25a46f936bd51dc29648b9cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 22 Jul 2023 03:41:52 +0000 Subject: [PATCH 049/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 47 files changed, 6209 insertions(+), 5341 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ac9fb65 --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var u=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c84a13a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;soDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 16d5ec3..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a547655..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 24c6cb7..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index df4fcda..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..842946e --- /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 c97f62b..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 21edc46..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 1b0ad81..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index 17671db..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 940d94f..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 4f7503bc17027ec915c4f554f1d4e326b3e5abcd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 07:02:02 +0000 Subject: [PATCH 050/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..16d5ec3 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '0fw2h', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..a547655 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..24c6cb7 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '0fw2n', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '0fw2h', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..7a10133 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '0fw2h', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '0fw2i', 'name', opts.name ) ); } } 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( '0fw30', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 36ddf29..df4fcda 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/object-assign": "github:stdlib-js/object-assign#main", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", "debug": "^2.6.9" From fa4b833576a346b4cd73e6413d2bb3716678b6cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 15:33:53 +0000 Subject: [PATCH 051/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ac9fb65..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var u=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c84a13a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;soDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 842946e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ac466e5156db07323e8ff7958fb15dd43a2b68e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 15:34:48 +0000 Subject: [PATCH 052/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 48 files changed, 6209 insertions(+), 5342 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 8695657..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T04:36:41.441Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ac9fb65 --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var u=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..c84a13a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;soDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 16d5ec3..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a547655..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 24c6cb7..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '0fw2n', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '0fw2h', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 7a10133..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '0fw2h', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '0fw2i', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '0fw30', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '0fw4x', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index df4fcda..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..aa295a8 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 3a3fa2fc06765f4d32429dbba5d84cc2df999acf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 18:35:07 +0000 Subject: [PATCH 053/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..989c107 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V,FD', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..8c7cca7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..bdc0a6a 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..60d620c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V,FD', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); } } 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( '1M52o,GE', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 36ddf29..df4fcda 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.0.8", "@stdlib/object-assign": "github:stdlib-js/object-assign#main", "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", "@stdlib/utils-inherit": "^0.0.8", "debug": "^2.6.9" From 0587e57554e0495399e3762c9e7bf14be19dc4ee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 19:00:42 +0000 Subject: [PATCH 054/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 81d6958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ac9fb65..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function h(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}var p=h(Object.freeze({__proto__:null,default:()=>()=>{}})),c=p("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("0fw2i","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("0fw30","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("0fw30","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("0fw30","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("0fw4x","highWaterMark",e.highWaterMark)):null:new TypeError(s("0fw2h",t))}var u=p;function w(e,o){var a,d,l,f,m;if(!(this instanceof w))return arguments.length>1?new w(e,o):1===arguments.length?new w(e):new w;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("0fw2n",o));m=o,f=b(a,e)}else arguments.length&&(r(e)?m=e:f=b(a,e));if(f)throw f;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,h),this;function h(e,t){if(m)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function g(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("0fw2h",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("0fw2n",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("0fw2h",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new w(n):new w(n,o)}function v(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("0fw2h",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new w(t,r):new w(t)}}o(w,t),e(w,"objectMode",g),e(w,"factory",v);export{w as default,v as factory,g as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index c84a13a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '0fw2h', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '0fw2i', 'name', opts.name ) );\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( '0fw30', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '0fw30', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '0fw4x', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '0fw2n', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '0fw2h', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;soDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index aa295a8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f90df363940c7b0d28416204c12e895a15c36200 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 19:01:35 +0000 Subject: [PATCH 055/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 50 files changed, 6209 insertions(+), 5353 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -289,7 +288,7 @@ s1.end(); ## 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]. @@ -359,9 +358,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5bed152 --- /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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function w(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",w),e(g,"factory",M);export{g as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..43f51d1 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;soDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 989c107..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c7cca7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index bdc0a6a..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 60d620c..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V,FD', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index df4fcda..9376795 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-number": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/object-assign": "github:stdlib-js/object-assign#main", - "@stdlib/streams-node-inspect": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/utils-inherit": "^0.0.8", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-string": "^0.0.8", - "@stdlib/streams-node-stdout": "^0.0.7", - "@stdlib/streams-node-transform": "^0.0.7", - "@stdlib/utils-next-tick": "^0.0.8", - "@stdlib/utils-noop": "^0.0.14", - "@stdlib/utils-parse-json": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9c36b23 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 108ee824a46fb75e4d08a56e267e7bedf1c98c46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 20:59:32 +0000 Subject: [PATCH 056/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..989c107 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V,FD', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..8c7cca7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..bdc0a6a 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..60d620c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V,FD', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); } } 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( '1M52o,GE', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index b6994a6..d54c6e3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.0", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", "@stdlib/utils-inherit": "^0.1.0", "debug": "^2.6.9" From 70aa7ee17d9db2167c091d18a1c2620e70535927 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:11:15 +0000 Subject: [PATCH 057/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5bed152..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/streams-node-inspect@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-buffer@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function w(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",w),e(g,"factory",M);export{g as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 43f51d1..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;soDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9c36b23..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4fd9184f1a84c5029a213367c25b7d85c9480cd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:11:57 +0000 Subject: [PATCH 058/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 51 files changed, 6209 insertions(+), 5388 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 07d2943..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 1767d7c..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -300,7 +299,7 @@ s1.end(); ## 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]. @@ -370,9 +369,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..cb3952c --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..eb61aca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;4sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 989c107..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c7cca7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index bdc0a6a..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 60d620c..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V,FD', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d54c6e3..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-inherit": "^0.1.0", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-string": "^0.1.0", - "@stdlib/streams-node-stdout": "^0.1.0", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.0", - "@stdlib/utils-noop": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ab5fd5f --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 4b9bc3a24393c8b368d2c184cac4bb77c201814e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:14:31 +0000 Subject: [PATCH 059/147] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dc4778a..867df1f 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.1.0-esm/index.mjs'; ``` From 16d2bb903de96b3b54fb8fdb015661dbc95c3e84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 21:14:31 +0000 Subject: [PATCH 060/147] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 867df1f..6268027 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug/tags). For example, + ```javascript import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.1.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debu 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-debug@v0.1.0-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; ``` From 7467b151beba24639c31689046d34119733bec89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 08:28:21 +0000 Subject: [PATCH 061/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..989c107 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V,FD', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..8c7cca7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..bdc0a6a 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..60d620c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V,FD', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); } } 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( '1M52o,GE', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index b6994a6..d54c6e3 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.0", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", "@stdlib/utils-inherit": "^0.1.0", "debug": "^2.6.9" From c29bbd1e8adea3151207c73ab4991d19f5d4300c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 14:06:42 +0000 Subject: [PATCH 062/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index cb3952c..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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index eb61aca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;4sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ab5fd5f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d7d1d173edc65dd764b63e15d2cbd46c562dbba8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 14:07:32 +0000 Subject: [PATCH 063/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 43 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 6209 insertions(+), 5490 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 81dee48..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T03:01:45.589Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5f8eea8..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -300,7 +299,7 @@ s1.end(); ## 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]. @@ -370,9 +369,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44949ea --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e5b956 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 989c107..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c7cca7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index bdc0a6a..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 60d620c..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V,FD', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index d54c6e3..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/utils-inherit": "^0.1.0", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-string": "^0.1.0", - "@stdlib/streams-node-stdout": "^0.1.0", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.0", - "@stdlib/utils-noop": "^0.1.0", - "@stdlib/utils-parse-json": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..80309b0 --- /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 8723254..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 debugStream = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 97c2b48c62ff10d6db6f3e50832b982c57ea4cc0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 12:09:13 +0000 Subject: [PATCH 064/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..989c107 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V,FD', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..8c7cca7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..bdc0a6a 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..60d620c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V,FD', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); } } 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( '1M52o,GE', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 145d220..4751c20 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-inherit": "^0.1.1", "debug": "^2.6.9" From ca83480c074d39b21b3711cbbf6dbb92df9f48a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 15:51:29 +0000 Subject: [PATCH 065/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44949ea..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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.0-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.0-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.0-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.0-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e5b956..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 80309b0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d0527153dcbbff186e07105026517ac915f8333 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 15:52:19 +0000 Subject: [PATCH 066/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 43 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 52 files changed, 6209 insertions(+), 5489 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5f8eea8..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -300,7 +299,7 @@ s1.end(); ## 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]. @@ -370,9 +369,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8ff2d39 --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e5b956 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 989c107..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c7cca7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index bdc0a6a..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 60d620c..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V,FD', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4751c20..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/streams-node-stdout": "^0.1.1", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "@stdlib/utils-parse-json": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fc9bb9e --- /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 8723254..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 debugStream = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.factory.js b/test/test.factory.js deleted file mode 100644 index 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 cacf92b43a400f8b1739df5f6932c6d5af097df7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 08:36:48 +0000 Subject: [PATCH 067/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..989c107 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V,FD', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..8c7cca7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..bdc0a6a 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..60d620c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V,FD', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); } } 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( '1M52o,GE', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 145d220..4751c20 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-inherit": "^0.1.1", "debug": "^2.6.9" From f430d0b89e6eaf22cb771fd5476af47acfb864db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 15:13:45 +0000 Subject: [PATCH 068/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8ff2d39..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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e5b956..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fc9bb9e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From feba716134f2c611d3986255b3599f2db7cf9829 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 15:14:53 +0000 Subject: [PATCH 069/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 6209 insertions(+), 5488 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 11a97ae..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T03:09:05.595Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5f8eea8..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -300,7 +299,7 @@ s1.end(); ## 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]. @@ -370,9 +369,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5e184c1..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8ff2d39 --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e5b956 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 989c107..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c7cca7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index bdc0a6a..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 60d620c..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V,FD', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 4751c20..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/streams-node-stdout": "^0.1.1", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "@stdlib/utils-parse-json": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f1b4ecf --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 8d3b85a0ea63284123e024222fee1c10c69bb0e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 07:24:10 +0000 Subject: [PATCH 070/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..989c107 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V,FD', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..8c7cca7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..bdc0a6a 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b,GJ', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V,FD', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..60d620c 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V,FD', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); } } 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( '1M52o,GE', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 13ba4c7..6a8a56c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-inherit": "^0.1.1", "debug": "^2.6.9" From e69077769bf5dc02544aa3f3a43fc8cd30fbe80f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 02:50:16 +0000 Subject: [PATCH 071/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8ff2d39..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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e5b956..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f1b4ecf..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a7ff12707e02a1d619adf04cc557c2edd5ab8de2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 02:50:52 +0000 Subject: [PATCH 072/147] 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 | 51 +- benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 6209 insertions(+), 5483 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 33d801f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T03:19:47.819Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5f8eea8..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -300,7 +299,7 @@ s1.end(); ## 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]. @@ -370,9 +369,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/tree/esm diff --git a/benchmark/benchmark.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index d9609b0..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8ff2d39 --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e5b956 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index 989c107..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8c7cca7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index bdc0a6a..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b,GJ', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V,FD', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 60d620c..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V,FD', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W,Gh', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o,GE', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 6a8a56c..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/streams-node-stdout": "^0.1.1", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "@stdlib/utils-parse-json": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6a7c0c6 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 0fb454062d739035a5eb568e822149934ac86d83 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:42:22 +0000 Subject: [PATCH 073/147] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 315b2bb..aeab2ba 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-inherit": "^0.1.1", "debug": "^2.6.9" From 2f0749983779566af9e7bcf6019a9ca47eee7431 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 11:04:00 +0000 Subject: [PATCH 074/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8ff2d39..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/streams-node-inspect@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.1.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.1.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function p(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}var h=p(Object.freeze({__proto__:null,default:()=>()=>{}})),c=h("debug-stream"),j={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function b(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!f(e.name))?new TypeError(s("1M52W,Gh","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o,GE","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o,GE","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o,GE","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(s("1M54k,I9","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V,FD",t))}var u=h;function g(e,o){var a,d,l,m,f;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=i({},j),arguments.length>1){if(!r(o))throw new TypeError(s("1M52b,GJ",o));f=o,m=b(a,e)}else arguments.length&&(r(e)?f=e:m=b(a,e));if(m)throw m;return d=a.name?"debug-stream:"+a.name:"debug-stream",l=u(d),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,p),this;function p(e,t){if(f)return c("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),f(l,e,t);n(e)&&(e=e.toString()),e=JSON.stringify(e),c("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var n,o;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V,FD",e));if(n=i({},e),o=t,!r(t))throw new TypeError(s("1M52b,GJ",t))}else if(arguments.length)if(r(e))n={},o=e;else{if(!a(e))throw new TypeError(s("1M52V,FD",e));n=i({},e)}else n={};return n.objectMode=!0,void 0===o?new g(n):new g(n,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V,FD",e));t=i({},e)}else t={};return r;function r(e,r){return t.name=e,arguments.length>1?new g(t,r):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e5b956..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V,FD', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W,Gh', 'name', opts.name ) );\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( '1M52o,GE', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o,GE', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k,I9', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b,GJ', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V,FD', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;mtDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,WAAY,OAAQP,EAAKI,OAGpDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,WAAY,aAAcP,EAAKQ,aAG1DL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,WAAY,qBAAsBP,EAAKU,qBAGlEP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKW,gBAG7DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,WAAY,gBAAiBP,EAAKY,gBAG3D,KAhCC,IAAIN,UAAWC,EAAQ,WAAYN,GAiC5C,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,IAE1CG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAI1C,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,WAAYQ,GAE5C,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAE1CD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6a7c0c6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 84dc63f64d31ee38d89a749062015da0eea9916a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 11:04:20 +0000 Subject: [PATCH 075/147] 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 | 51 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 6209 insertions(+), 5489 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 f120d5c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:52:19.319Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 74a4a11..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -300,7 +299,7 @@ s1.end(); ## 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]. @@ -370,9 +369,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6dc2fa2..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[esm-url]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65d609b --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r 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/string-format@v0.1.1-esm/index.mjs";import s 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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import l 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 m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function u(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var b=u(Object.freeze({__proto__:null,default:()=>()=>{}})),f=b("debug-stream"),c={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function h(e,t){return a(t)?l(t,"name")&&(e.name=t.name,!p(e.name))?new TypeError(i("invalid option. `%s` option must be a string. Option: `%s`.","name",e.name)):l(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):l(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!d(e.readableObjectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","readableObjectMode",e.readableObjectMode)):l(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","allowHalfOpen",e.allowHalfOpen)):l(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(i("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t))}var j=b;function g(e,o){var a,l,d,m,p;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=s({},c),arguments.length>1){if(!n(o))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",o));p=o,m=h(a,e)}else arguments.length&&(n(e)?p=e:m=h(a,e));if(m)throw m;return l=a.name?"debug-stream:"+a.name:"debug-stream",d=j(l),f("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,u),this;function u(e,t){if(p)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),p(d,e,t);r(e)&&(e=e.toString()),e=JSON.stringify(e),f("Received a new chunk. Chunk: %s. Index: %d.",e,t),d("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var r,o;if(arguments.length>1){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));if(r=s({},e),o=t,!n(t))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(n(e))r={},o=e;else{if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));r=s({},e)}else r={};return r.objectMode=!0,void 0===o?new g(r):new g(r,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new g(t,n):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f3c1b25 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;0sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,8DAA+D,OAAQP,EAAKI,OAGvGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,+DAAgE,qBAAsBP,EAAKU,qBAGtHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,+DAAgE,gBAAiBP,EAAKW,gBAGjHR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKY,gBAG1H,KAhCC,IAAIN,UAAWC,EAAQ,qEAAsEN,GAiCtG,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,IAEtGG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAIpG,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,GAExG,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b9f70fe..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( 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 debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 64f25a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 084a9f9..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 47a870b..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -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, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); - } - } - 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, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - 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 null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index aeab2ba..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/streams-node-stdout": "^0.1.1", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "@stdlib/utils-parse-json": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..234ce74 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 619734d31bf30a17c9ce6414df50ba8967b40177 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 05:08:58 +0000 Subject: [PATCH 076/147] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 315b2bb..aeab2ba 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.1.1", "@stdlib/object-assign": "^0.1.0", "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", "@stdlib/utils-inherit": "^0.1.1", "debug": "^2.6.9" From 1e198624a9e81f8c786dd34484f1a2c4d1f88602 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:24:28 +0000 Subject: [PATCH 077/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65d609b..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/streams-node-inspect@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r 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/string-format@v0.1.1-esm/index.mjs";import s 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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import l 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 m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function u(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var b=u(Object.freeze({__proto__:null,default:()=>()=>{}})),f=b("debug-stream"),c={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function h(e,t){return a(t)?l(t,"name")&&(e.name=t.name,!p(e.name))?new TypeError(i("invalid option. `%s` option must be a string. Option: `%s`.","name",e.name)):l(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):l(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!d(e.readableObjectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","readableObjectMode",e.readableObjectMode)):l(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","allowHalfOpen",e.allowHalfOpen)):l(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(i("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t))}var j=b;function g(e,o){var a,l,d,m,p;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=s({},c),arguments.length>1){if(!n(o))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",o));p=o,m=h(a,e)}else arguments.length&&(n(e)?p=e:m=h(a,e));if(m)throw m;return l=a.name?"debug-stream:"+a.name:"debug-stream",d=j(l),f("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,u),this;function u(e,t){if(p)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),p(d,e,t);r(e)&&(e=e.toString()),e=JSON.stringify(e),f("Received a new chunk. Chunk: %s. Index: %d.",e,t),d("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var r,o;if(arguments.length>1){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));if(r=s({},e),o=t,!n(t))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(n(e))r={},o=e;else{if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));r=s({},e)}else r={};return r.objectMode=!0,void 0===o?new g(r):new g(r,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new g(t,n):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f3c1b25..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;0sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,8DAA+D,OAAQP,EAAKI,OAGvGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,+DAAgE,qBAAsBP,EAAKU,qBAGtHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,+DAAgE,gBAAiBP,EAAKW,gBAGjHR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKY,gBAG1H,KAhCC,IAAIN,UAAWC,EAAQ,qEAAsEN,GAiCtG,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,IAEtGG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAIpG,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,GAExG,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 234ce74..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eeb2a2dfa745964d44fa951c4652aab6c81484ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 10:24:48 +0000 Subject: [PATCH 078/147] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 6209 insertions(+), 5494 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 d1a336b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T03:27:42.266Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 74a4a11..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..65d609b --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r 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/string-format@v0.1.1-esm/index.mjs";import s 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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import l 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 m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function u(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var b=u(Object.freeze({__proto__:null,default:()=>()=>{}})),f=b("debug-stream"),c={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function h(e,t){return a(t)?l(t,"name")&&(e.name=t.name,!p(e.name))?new TypeError(i("invalid option. `%s` option must be a string. Option: `%s`.","name",e.name)):l(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):l(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!d(e.readableObjectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","readableObjectMode",e.readableObjectMode)):l(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","allowHalfOpen",e.allowHalfOpen)):l(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(i("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t))}var j=b;function g(e,o){var a,l,d,m,p;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=s({},c),arguments.length>1){if(!n(o))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",o));p=o,m=h(a,e)}else arguments.length&&(n(e)?p=e:m=h(a,e));if(m)throw m;return l=a.name?"debug-stream:"+a.name:"debug-stream",d=j(l),f("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,u),this;function u(e,t){if(p)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),p(d,e,t);r(e)&&(e=e.toString()),e=JSON.stringify(e),f("Received a new chunk. Chunk: %s. Index: %d.",e,t),d("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var r,o;if(arguments.length>1){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));if(r=s({},e),o=t,!n(t))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(n(e))r={},o=e;else{if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));r=s({},e)}else r={};return r.objectMode=!0,void 0===o?new g(r):new g(r,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new g(t,n):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f3c1b25 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;0sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,8DAA+D,OAAQP,EAAKI,OAGvGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,+DAAgE,qBAAsBP,EAAKU,qBAGtHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,+DAAgE,gBAAiBP,EAAKW,gBAGjHR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKY,gBAG1H,KAhCC,IAAIN,UAAWC,EAAQ,qEAAsEN,GAiCtG,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,IAEtGG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAIpG,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,GAExG,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b9f70fe..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( 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 debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 64f25a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 084a9f9..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 47a870b..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -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, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); - } - } - 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, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - 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 null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index aeab2ba..d8c0e67 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-number": "^0.1.1", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/object-assign": "^0.1.0", - "@stdlib/streams-node-inspect": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/utils-inherit": "^0.1.1", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/streams-node-stdout": "^0.1.1", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.1.1", - "@stdlib/utils-noop": "^0.1.1", - "@stdlib/utils-parse-json": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fe1231c --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 3ae21f5f36bcfcf8fca38fe1bd1b48123d3ddd0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 09:05:46 +0000 Subject: [PATCH 079/147] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index deee542..fb6e0d0 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.0", "@stdlib/object-assign": "^0.2.0", "@stdlib/streams-node-inspect": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", "@stdlib/utils-inherit": "^0.2.0", "debug": "^2.6.9" From d6b6f1e10cc42f8460e336dbdf39ecbfc94a20f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 18:02:42 +0000 Subject: [PATCH 080/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 65d609b..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/streams-node-inspect@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r 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/string-format@v0.1.1-esm/index.mjs";import s 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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.1.0-esm/index.mjs";import l 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 m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.1.1-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.1.1-esm/index.mjs";function u(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var b=u(Object.freeze({__proto__:null,default:()=>()=>{}})),f=b("debug-stream"),c={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function h(e,t){return a(t)?l(t,"name")&&(e.name=t.name,!p(e.name))?new TypeError(i("invalid option. `%s` option must be a string. Option: `%s`.","name",e.name)):l(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):l(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!d(e.readableObjectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","readableObjectMode",e.readableObjectMode)):l(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","allowHalfOpen",e.allowHalfOpen)):l(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(i("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t))}var j=b;function g(e,o){var a,l,d,m,p;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=s({},c),arguments.length>1){if(!n(o))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",o));p=o,m=h(a,e)}else arguments.length&&(n(e)?p=e:m=h(a,e));if(m)throw m;return l=a.name?"debug-stream:"+a.name:"debug-stream",d=j(l),f("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,u),this;function u(e,t){if(p)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),p(d,e,t);r(e)&&(e=e.toString()),e=JSON.stringify(e),f("Received a new chunk. Chunk: %s. Index: %d.",e,t),d("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var r,o;if(arguments.length>1){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));if(r=s({},e),o=t,!n(t))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(n(e))r={},o=e;else{if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));r=s({},e)}else r={};return r.objectMode=!0,void 0===o?new g(r):new g(r,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new g(t,n):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f3c1b25..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;0sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,8DAA+D,OAAQP,EAAKI,OAGvGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,+DAAgE,qBAAsBP,EAAKU,qBAGtHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,+DAAgE,gBAAiBP,EAAKW,gBAGjHR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKY,gBAG1H,KAhCC,IAAIN,UAAWC,EAAQ,qEAAsEN,GAiCtG,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,IAEtGG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAIpG,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,GAExG,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fe1231c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c55a1cf2bfc959f548b5fd975af59f8081c6c88a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 18:03:02 +0000 Subject: [PATCH 081/147] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 6209 insertions(+), 5497 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0dbc4c2..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..558794d --- /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/streams-node-inspect@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import r 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/string-format@v0.1.1-esm/index.mjs";import s 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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import l 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 m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";function u(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var b=u(Object.freeze({__proto__:null,default:()=>()=>{}})),f=b("debug-stream"),c={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function h(e,t){return a(t)?l(t,"name")&&(e.name=t.name,!p(e.name))?new TypeError(i("invalid option. `%s` option must be a string. Option: `%s`.","name",e.name)):l(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):l(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!d(e.readableObjectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","readableObjectMode",e.readableObjectMode)):l(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","allowHalfOpen",e.allowHalfOpen)):l(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(i("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t))}var j=b;function g(e,o){var a,l,d,m,p;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=s({},c),arguments.length>1){if(!n(o))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",o));p=o,m=h(a,e)}else arguments.length&&(n(e)?p=e:m=h(a,e));if(m)throw m;return l=a.name?"debug-stream:"+a.name:"debug-stream",d=j(l),f("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,u),this;function u(e,t){if(p)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),p(d,e,t);r(e)&&(e=e.toString()),e=JSON.stringify(e),f("Received a new chunk. Chunk: %s. Index: %d.",e,t),d("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var r,o;if(arguments.length>1){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));if(r=s({},e),o=t,!n(t))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(n(e))r={},o=e;else{if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));r=s({},e)}else r={};return r.objectMode=!0,void 0===o?new g(r):new g(r,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new g(t,n):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f3c1b25 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;0sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,8DAA+D,OAAQP,EAAKI,OAGvGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,+DAAgE,qBAAsBP,EAAKU,qBAGtHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,+DAAgE,gBAAiBP,EAAKW,gBAGjHR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKY,gBAG1H,KAhCC,IAAIN,UAAWC,EAAQ,qEAAsEN,GAiCtG,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,IAEtGG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAIpG,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,GAExG,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index b9f70fe..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( 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 debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 64f25a7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 084a9f9..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/string-format' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index 47a870b..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -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, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); - } - } - 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, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - 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 null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index fb6e0d0..774f1e3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/object-assign": "^0.2.0", - "@stdlib/streams-node-inspect": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/utils-inherit": "^0.2.0", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.1.1", - "@stdlib/streams-node-stdout": "^0.2.0", - "@stdlib/streams-node-transform": "^0.1.0", - "@stdlib/utils-next-tick": "^0.2.0", - "@stdlib/utils-noop": "^0.2.0", - "@stdlib/utils-parse-json": "^0.1.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e5471de --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 6e7d60099908835952d7f033862ae8addaaa6eb9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:16:23 +0000 Subject: [PATCH 082/147] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3c473cf..edbdd54 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.2.0-esm/index.mjs'; ``` From 0340fc23df208d18f67d140748b00060245d5102 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:16:23 +0000 Subject: [PATCH 083/147] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index edbdd54..e4163d6 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug/tags). For example, + ```javascript import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.2.0-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debu 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-debug@v0.2.0-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; ``` From 673e159f0c9dfc6f5aa36ed1721f1c98daee6dcb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 16:42:03 +0000 Subject: [PATCH 084/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index fc3f01d..65629af 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-inherit": "^0.2.1", "debug": "^2.6.9" From b19e77b7f9ef9ebb1c3fe0ea0f5097e40580ff87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:30:52 +0000 Subject: [PATCH 085/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6477 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 558794d..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/streams-node-inspect@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import r 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/string-format@v0.1.1-esm/index.mjs";import s 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 a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.0-esm/index.mjs";import l 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 m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.0-esm/index.mjs";import{isPrimitive as p}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.0-esm/index.mjs";function u(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var b=u(Object.freeze({__proto__:null,default:()=>()=>{}})),f=b("debug-stream"),c={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function h(e,t){return a(t)?l(t,"name")&&(e.name=t.name,!p(e.name))?new TypeError(i("invalid option. `%s` option must be a string. Option: `%s`.","name",e.name)):l(t,"objectMode")&&(e.objectMode=t.objectMode,!d(e.objectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","objectMode",e.objectMode)):l(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!d(e.readableObjectMode))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","readableObjectMode",e.readableObjectMode)):l(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(i("invalid option. `%s` option must be a boolean. Option: `%s`.","allowHalfOpen",e.allowHalfOpen)):l(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!m(e.highWaterMark))?new TypeError(i("invalid option. `%s` option must be a nonnegative number. Option: `%s`.","highWaterMark",e.highWaterMark)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",t))}var j=b;function g(e,o){var a,l,d,m,p;if(!(this instanceof g))return arguments.length>1?new g(e,o):1===arguments.length?new g(e):new g;if(a=s({},c),arguments.length>1){if(!n(o))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",o));p=o,m=h(a,e)}else arguments.length&&(n(e)?p=e:m=h(a,e));if(m)throw m;return l=a.name?"debug-stream:"+a.name:"debug-stream",d=j(l),f("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,u),this;function u(e,t){if(p)return f("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),p(d,e,t);r(e)&&(e=e.toString()),e=JSON.stringify(e),f("Received a new chunk. Chunk: %s. Index: %d.",e,t),d("Chunk: %s. Index: %d.",e,t)}}function v(e,t){var r,o;if(arguments.length>1){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));if(r=s({},e),o=t,!n(t))throw new TypeError(i("invalid argument. Callback argument must be a function. Value: `%s`.",t))}else if(arguments.length)if(n(e))r={},o=e;else{if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));r=s({},e)}else r={};return r.objectMode=!0,void 0===o?new g(r):new g(r,o)}function w(e){var t;if(arguments.length){if(!a(e))throw new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e));t=s({},e)}else t={};return n;function n(e,n){return t.name=e,arguments.length>1?new g(t,n):new g(t)}}o(g,t),e(g,"objectMode",v),e(g,"factory",w);export{g as default,w as factory,v as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f3c1b25..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/debug.js","../lib/namespace.js","../lib/validate.js","../lib/logger.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\nvar logger = require( 'debug' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/string-format';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","NAMESPACE","logger","JSON","stringify","InspectStream","call","inspect","chunk","idx","toString","isBuffer","Stream","streamFactory","debugStream","inherit","setReadOnly","main","factory"],"mappings":";;0sDA4BIA,EANSC,ECAE,iFCuBf,SAASC,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,8DAA+D,OAAQP,EAAKI,OAGvGD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,+DAAgE,aAAcP,EAAKQ,aAG9GL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,+DAAgE,qBAAsBP,EAAKU,qBAGtHP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,+DAAgE,gBAAiBP,EAAKW,gBAGjHR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,0EAA2E,gBAAiBP,EAAKY,gBAG1H,KAhCC,IAAIN,UAAWC,EAAQ,qEAAsEN,GAiCtG,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,IAEtGG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFqB,gBAAkBzB,EAAKI,KHzEjB,eG6EdY,EAAMU,EAAQtB,GAEdP,EAAO,yEAA0E8B,KAAKC,UAAW5B,IACjG6B,EAAcC,KAAMX,KAAMnB,EAAM+B,GAEzBZ,KAUP,SAASY,EAASC,EAAOC,GACxB,GAAKf,EAEJ,OADArB,EAAO,8CAA+CmC,EAAME,WAAYD,GACjEf,EAAIF,EAAKgB,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQL,KAAKC,UAAWI,GACxBnC,EAAO,8CAA+CmC,EAAOC,GAC7DjB,EAAK,wBAAyBgB,EAAOC,EACrC,CACF,CCvEA,SAASzB,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAIpG,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,uEAAwEQ,GAExG,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIkB,EAAQpC,GAEb,IAAIoC,EAAQpC,EAAMkB,EAC1B,CC7BA,SAASmB,EAAepC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,qEAAsEN,IAEpGD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAAOsC,EAYP,SAASA,EAAalC,EAAMW,GAE3B,OADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EAChB,IAAIe,EAAQpC,EAAMe,GAEnB,IAAIqB,EAAQpC,EACnB,CACF,CF8CAuC,EAASzB,EAAae,GGrDtBW,EAAAC,EAAA,aAAAjC,GACAgC,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e5471de..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 82846b7760be0c8c87893965517a13e47a933234 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:31:17 +0000 Subject: [PATCH 086/147] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 4874 insertions(+), 5491 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d98d3a2 --- /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/streams-node-inspect@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 65629af..5995e4a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform stream for debugging stream pipelines.", "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,49 +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-function": "^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/object-assign": "^0.2.1", - "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "debug": "^2.6.9" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/streams-node-stdout": "^0.2.1", - "@stdlib/streams-node-transform": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..03ab157 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 d9893f1684b2000e75f8e895becc1971c852b2fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:11:20 +0000 Subject: [PATCH 087/147] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64d565c..0235269 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.2.1-esm/index.mjs'; ``` From f886b40e4e9cf964aa0a034877d34e34d6efd345 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 19:11:21 +0000 Subject: [PATCH 088/147] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0235269..a317b99 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug/tags). For example, + ```javascript import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.2.1-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debu 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-debug@v0.2.1-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; ``` From 7c590162346cc643e168715f51809f66da37eb72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 04:39:30 +0000 Subject: [PATCH 089/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index dca4f34..08cffa6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-inherit": "^0.2.1", "debug": "^2.6.9", From 6481a9184f56bd96cb6a5bd9ad6a92c79f32dd6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:08:37 +0000 Subject: [PATCH 090/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d98d3a2..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/streams-node-inspect@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 03ab157..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9d107b44c2943b2fd3a00dcb4a6e2d510684c5a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 09:08:51 +0000 Subject: [PATCH 091/147] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5494 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 3e39e7e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T03:22:32.981Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d39f774 --- /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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 08cffa6..5995e4a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.1", - "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/streams-node-stdout": "^0.2.1", - "@stdlib/streams-node-transform": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dae7b54 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 f75bd967ed365e94f791416dfb7e2e1db7b450bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 04:07:46 +0000 Subject: [PATCH 092/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index dca4f34..08cffa6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-inherit": "^0.2.1", "debug": "^2.6.9", From 25bbcfa200388deefa8eacb2f54f05393d303c74 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:44:03 +0000 Subject: [PATCH 093/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d39f774..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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dae7b54..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e7e98ce73e074e5734440ef1c2f5842ecb48ee7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:44:13 +0000 Subject: [PATCH 094/147] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5497 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 a35056b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:45:56.226Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d39f774 --- /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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 08cffa6..5995e4a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.1", - "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/streams-node-stdout": "^0.2.1", - "@stdlib/streams-node-transform": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dae7b54 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 4916f22c3de8afb3da3e9259acf3a02b9b7e826a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 00:18:29 +0000 Subject: [PATCH 095/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index dca4f34..08cffa6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-inherit": "^0.2.1", "debug": "^2.6.9", From 152d7cc501bd08cd05baeccfb1318c18a1e26c53 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:29:44 +0000 Subject: [PATCH 096/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d39f774..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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dae7b54..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 880d47485f7fddecacf91e53328dc6880972f0a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 05:29:57 +0000 Subject: [PATCH 097/147] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 4874 insertions(+), 5498 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d39f774 --- /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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 08cffa6..5995e4a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.1", - "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/streams-node-stdout": "^0.2.1", - "@stdlib/streams-node-transform": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dae7b54 --- /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 086b943..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances'); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 ddb70155ba4e1e0ae5d3a571eac8aa09219d940a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jul 2024 17:17:42 +0000 Subject: [PATCH 098/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index dca4f34..08cffa6 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.1", "@stdlib/object-assign": "^0.2.1", "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", "@stdlib/utils-inherit": "^0.2.1", "debug": "^2.6.9", From 0868e70182bac3b60b26d709a12bc8881e1bee7b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jul 2024 17:28:37 +0000 Subject: [PATCH 099/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d39f774..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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dae7b54..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4a0d764ec29dbbceb3d12bec8a47e843a17859dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jul 2024 17:28:54 +0000 Subject: [PATCH 100/147] 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 | 98 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 4874 insertions(+), 5602 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d39f774 --- /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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 08cffa6..5995e4a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.1", - "@stdlib/streams-node-inspect": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/utils-inherit": "^0.2.1", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.1", - "@stdlib/streams-node-stdout": "^0.2.1", - "@stdlib/streams-node-transform": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "@stdlib/utils-parse-json": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..dae7b54 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 c43208cd6ab7184773f207bed5cbc89ccfa51dfb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:28:33 +0000 Subject: [PATCH 101/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index 9cd9d4e..aa3b936 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.1", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From b4a42e664eb9ddd8cd9c4a2a70cce4c185606a59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:35:48 +0000 Subject: [PATCH 102/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d39f774..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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.1-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.1-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.1-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.1-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dae7b54..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d0d0d336f7d3516ab3e2514582a4867eb05f557 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:36:00 +0000 Subject: [PATCH 103/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 53 files changed, 4874 insertions(+), 5715 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..107a5fd --- /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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index aa3b936..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.1", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.1", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..25842a5 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 7ddac3eccdab8e89a50141fb164dec5a066c5286 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:38:31 +0000 Subject: [PATCH 104/147] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2aee0f..c8ea8e5 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ limitations under the License. ## Usage ```javascript -import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug@esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.2.2-esm/index.mjs'; ``` From 8e7e9941d83ee34f85db86302401b46b84479f3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 01:38:32 +0000 Subject: [PATCH 105/147] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c8ea8e5..017a03a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@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-debug/tags). For example, + ```javascript import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@v0.2.2-esm/index.mjs'; ``` @@ -48,7 +53,7 @@ import debugStream from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debu 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-debug@v0.2.2-esm/index.mjs'; +import { factory, objectMode } from 'https://cdn.jsdelivr.net/gh/stdlib-js/streams-node-debug@esm/index.mjs'; ``` From 4af1ea02c531a13bb6bc9c4cf2f004c9483157a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 04:42:33 +0000 Subject: [PATCH 106/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 765c32b770f4e1b1c6f0e4e5ed3556d9ea43e167 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:52:08 +0000 Subject: [PATCH 107/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 107a5fd..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/streams-node-inspect@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 25842a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5c9fcccade9fbc0e978e488f4849ba9f15caedcc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:52:21 +0000 Subject: [PATCH 108/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5655 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 54575da..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T03:22:56.106Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 9134dcf41c86231024f058b56d68464cfbf48c18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:36:06 +0000 Subject: [PATCH 109/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 0962ca949e99674b4b6f86637240ce1de72ae7b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:50:14 +0000 Subject: [PATCH 110/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d110abc500aee0cf7fa43f28ae76ad57140e861 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:50:30 +0000 Subject: [PATCH 111/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5718 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 eefb50b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T18:33:27.759Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 42733d2e4ab836d198da0de83f429b6a7042442f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:50:45 +0000 Subject: [PATCH 112/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From a01ca8251bf6a02654876887dfcc5ca5be3ddb0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:49:54 +0000 Subject: [PATCH 113/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 143388a3785ae9ff4cf59c9be0faf081e2df55c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:50:08 +0000 Subject: [PATCH 114/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5717 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 a6eba11..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:35:26.445Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 73851776967bfb70f811e8e9d8d7188964f9ab56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 05:00:13 +0000 Subject: [PATCH 115/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 8ca779110b95265799ab4f3dab9ee6890fda8adb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:01:25 +0000 Subject: [PATCH 116/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c48269ea9ff59360259cdbc30c58d2a050ed9f7d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 09:01:35 +0000 Subject: [PATCH 117/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5717 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 e394cc9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:45:17.429Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 927dc4aa78a0c2322d9f8b3d78f415b758ab0a7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:55:49 +0000 Subject: [PATCH 118/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From d1580840b652e3b4acd60335af84bb76e4c18f6d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:27:30 +0000 Subject: [PATCH 119/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 188c3e5571fe5f15b86d533e2b178bdf9a94eff5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:27:42 +0000 Subject: [PATCH 120/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 54 files changed, 4874 insertions(+), 5717 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 261c66f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:48:34.421Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 db5337eaa6540510d942106f9c79065e082f2936 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 05:12:01 +0000 Subject: [PATCH 121/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 20a3896d945f6de2ea41e630e5a03ca9502a9f10 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:59:03 +0000 Subject: [PATCH 122/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cc0148187c086522ededfe95dcb6dd0e58fe57df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:59:19 +0000 Subject: [PATCH 123/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5822 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 1921773..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:53:23.897Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 b29efcafcf42893ee0110ef841d92941e6590632 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:25:41 +0000 Subject: [PATCH 124/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 5dafcb7af6d1edf93b4a0bb5bfc1c00a22b09789 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:40:35 +0000 Subject: [PATCH 125/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a622ad3e40a3ae588c8062543fdb3dd0badee50d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:40:59 +0000 Subject: [PATCH 126/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5822 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c1e61cf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:55:19.963Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20faa1f --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 7f92a1922be1faabc6cc7c39fe18504a4ba2f95b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:23:10 +0000 Subject: [PATCH 127/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From e1dd5f03b8d1c3b9b5b942c11e1bbc2ab402823b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:59:04 +0000 Subject: [PATCH 128/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20faa1f..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 091b05cc951fa891069078ebc047d58d3fc922a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:59:22 +0000 Subject: [PATCH 129/147] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5822 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.js delete mode 100644 lib/object_mode.js delete mode 100644 lib/validate.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.factory.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.object_mode.js delete mode 100644 test/test.validate.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 78d98c1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-13T02:10:48.067Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 51b6349..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 dea4eca2c3cd6ae6fe2a5647f57986fe3e34dabe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:30:01 +0000 Subject: [PATCH 130/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 18a616becb73a57dfc3796d957a5a42bc2f52044 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:03:32 +0000 Subject: [PATCH 131/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c77e738..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c4a6531105e1862f09e8ef7b8cb6e4090e04c0e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 02:03:50 +0000 Subject: [PATCH 132/147] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5825 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 5804b85..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:19:00.979Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 ff94792a93a865a2e433658b61fe1ee377b99385 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:27:39 +0000 Subject: [PATCH 133/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 443f3e0995ba7231fe843502566415547ee296a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 02:03:09 +0000 Subject: [PATCH 134/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c77e738..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f4dbfea303b2ed17adfb7709917e75bb751b6600 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 02:03:28 +0000 Subject: [PATCH 135/147] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5825 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 8c045d4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T01:18:52.229Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 19cfbdca39db53f7a0bea584240ef9a78c7d2756 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:30:19 +0000 Subject: [PATCH 136/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From b62f712d6c32b1eb4bb0f0b6d3c332cf597c81b8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:30:46 +0000 Subject: [PATCH 137/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c77e738..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e8af5931a00faa79e71f9f91b4fd49c062919c0b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 00:31:07 +0000 Subject: [PATCH 138/147] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5825 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 d897ced..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T00:29:52.658Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 4e06460de727d8b262afc53b1af7c8582f21ce2f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:16:49 +0000 Subject: [PATCH 139/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From e69e38ea86941346c20ef172a7dead5bd0a78dc5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:31:14 +0000 Subject: [PATCH 140/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c77e738..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5fb9221bd98a276d2a94f6d5a97abb0918a2d085 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:31:29 +0000 Subject: [PATCH 141/147] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5825 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 0438de1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-14T01:05:48.421Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 f8c9a200e1c72ebe84a3c755e0b8c6bebfbcc27f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:06:38 +0000 Subject: [PATCH 142/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From f2e7a5b6baf0f4224f4264cb0a38cda08f075653 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:34:47 +0000 Subject: [PATCH 143/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c77e738..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5e1285582a11cb336fa0f29f70342bf853555aca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:35:04 +0000 Subject: [PATCH 144/147] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5825 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 10a6cc8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T01:02:49.994Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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 7a7d2df125b3d43510d9d6462c2c85f0eba9afd1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:01:05 +0000 Subject: [PATCH 145/147] Transform error messages --- lib/factory.js | 4 ++-- lib/main.js | 4 ++-- lib/object_mode.js | 8 ++++---- lib/validate.js | 14 +++++++------- package.json | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/factory.js b/lib/factory.js index b9f70fe..a98d587 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 Stream = require( './main.js' ); @@ -58,7 +58,7 @@ function streamFactory( 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( '1M52V', options ) ); } opts = assign( {}, options ); } else { diff --git a/lib/main.js b/lib/main.js index 64f25a7..0d3a697 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,7 +23,7 @@ var InspectStream = require( '@stdlib/streams-node-inspect' ); var isFunction = require( '@stdlib/assert-is-function' ); var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var assign = require( '@stdlib/object-assign' ); var inherit = require( '@stdlib/utils-inherit' ); var debug = require( './debug.js' ); @@ -78,7 +78,7 @@ function DebugStream( options, clbk ) { opts = assign( {}, DEFAULTS ); if ( arguments.length > 1 ) { if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } cb = clbk; err = validate( opts, options ); diff --git a/lib/object_mode.js b/lib/object_mode.js index 084a9f9..836a004 100644 --- a/lib/object_mode.js +++ b/lib/object_mode.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); 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 Stream = require( './main.js' ); @@ -58,12 +58,12 @@ function objectMode( options, clbk ) { var cb; if ( arguments.length > 1 ) { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); cb = clbk; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( '1M52b', clbk ) ); } } else if ( arguments.length ) { if ( isFunction( options ) ) { @@ -71,7 +71,7 @@ function objectMode( options, clbk ) { cb = options; } else { if ( !isObject( options ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( '1M52V', options ) ); } opts = assign( {}, options ); } diff --git a/lib/validate.js b/lib/validate.js index 47a870b..dc16c26 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,7 +25,7 @@ var hasOwnProp = require( '@stdlib/assert-has-own-property' ); var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -45,36 +45,36 @@ var format = require( '@stdlib/string-format' ); */ function validate( opts, options ) { if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + return new TypeError( format( '1M52V', options ) ); } if ( hasOwnProp( options, 'name' ) ) { opts.name = options.name; if ( !isString( opts.name ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) ); + return new TypeError( format( '1M52W', 'name', opts.name ) ); } } 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( '1M52o', 'objectMode', opts.objectMode ) ); } } if ( hasOwnProp( options, 'readableObjectMode' ) ) { opts.readableObjectMode = options.readableObjectMode; if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) ); + return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); } } if ( hasOwnProp( options, 'allowHalfOpen' ) ) { opts.allowHalfOpen = options.allowHalfOpen; if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) ); + return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); } } 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( '1M54k', 'highWaterMark', opts.highWaterMark ) ); } } return null; diff --git a/package.json b/package.json index c878fde..9e48ad8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@stdlib/assert-is-string": "^0.2.2", "@stdlib/object-assign": "^0.2.2", "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", "@stdlib/utils-inherit": "^0.2.2", "debug": "^2.6.9", From 2c8c9f190cdb1581529f4c3731e97024cb321d6a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:24:37 +0000 Subject: [PATCH 146/147] Remove files --- index.d.ts | 295 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5142 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 3f56e75..0000000 --- a/index.d.ts +++ /dev/null @@ -1,295 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Transform } from 'stream'; - -/** -* Interface defining stream options. -*/ -interface Options { - /** - * Debug namespace. - */ - name?: string; - - /** - * Specifies whether a stream should operate in object mode (default: `false`). - */ - objectMode?: boolean; - - /** - * Specifies the `Buffer` level for when `write()` starts returning `false`. - */ - highWaterMark?: number; - - /** - * Specifies whether the stream should remain open even if one side ends (default: `false`). - */ - allowHalfOpen?: boolean; - - /** - * Specifies whether the readable side should be in object mode (default: `false`). - */ - readableObjectMode?: boolean; -} - -/** -* Callback function invoked upon receiving data. -*/ -type Nullary = () => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -*/ -type Unary = ( debug: Function ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Binary = ( debug: Function, chunk: any ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Ternary = ( debug: Function, chunk: any, idx: number ) => void; - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface defining a stream constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( options: Options, clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var DebugStream = debugStream; - * var stream = new DebugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - new( clbk?: Callback ): Transform; // newable - - /** - * Debug stream constructor. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream({ - * 'name': 'my-stream' - * }); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( options: Options, clbk?: Callback ): Transform; // callable - - /** - * Debug stream constructor. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream(); - * - * stream.write( 'a' ); - * stream.write( 'b' ); - * stream.write( 'c' ); - * stream.end(); - */ - ( clbk?: Callback ): Transform; // callable - - /** - * Creates a reusable debug stream factory. - * - * @param options - stream options - * @param options.objectMode - specifies whether the stream should operate in object mode (default: false) - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @returns debug stream factory - * - * @example - * var opts = { - * 'objectMode': true, - * 'highWaterMark': 64 - * }; - * - * var factory = debugStream.factory( opts ); - * - * // Assign each stream to a separate debug namespace... - * var streams = []; - * var i; - * for ( i = 0; i < 10; i++ ) { - * streams.push( factory( 'stream '+i ) ); - * } - */ - factory( options?: Options ): ( name: string, clbk?: Callback ) => Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param options - stream options - * @param options.name - debug namespace - * @param options.highWaterMark - specifies the `Buffer` level for when `write()` starts returning `false` - * @param options.allowHalfOpen - specifies whether the stream should remain open even if one side ends (default: false) - * @param options.readableObjectMode - specifies whether the readable side should be in object mode (default: false) - * @param clbk - callback to invoke upon receiving data - * @throws must provide valid options - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode({ - * 'name': 'my-stream' - * }); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( options: Options, clbk?: Callback ): Transform; - - /** - * Returns a debug stream with `objectMode` set to `true`. - * - * @param clbk - callback to invoke upon receiving data - * @returns debug stream - * - * @example - * var stream = debugStream.objectMode(); - * - * stream.write( {'value': 'a'} ); - * stream.write( {'value': 'b'} ); - * stream.write( {'value': 'c'} ); - * stream.end(); - */ - objectMode( clbk?: Callback ): Transform; -} - -/** -* Returns a debug stream. -* -* @param options - stream options -* @throws must provide valid options -* @returns stream instance -* -* @example -* var DebugStream = debugStream; -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -* -* @example -* var stream = debugStream.objectMode(); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -declare var inspectStream: Constructor; - - -// EXPORTS // - -export = inspectStream; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c77e738..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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index db477c5..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2584f36..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e0954637c82176e06748e5f0c041c998257e4dc5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:24:50 +0000 Subject: [PATCH 147/147] 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 | 210 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.throughput.js | 228 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 17 - dist/index.js.map | 7 - docs/repl.txt | 128 - docs/types/test.ts | 152 - examples/index.js | 93 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/debug.js | 34 - lib/defaults.json | 6 - lib/factory.js | 91 - lib/index.js | 85 - lib/logger.js | 28 - lib/main.js | 137 - lib/namespace.js | 23 - lib/object_mode.js | 91 - lib/validate.js | 86 - package.json | 71 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.factory.js | 146 - test/test.js | 43 - test/test.main.js | 339 -- test/test.object_mode.js | 184 - test/test.validate.js | 219 - 55 files changed, 4874 insertions(+), 5825 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.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 (100%) 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/logger.js delete mode 100644 lib/main.js delete mode 100644 lib/namespace.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 62c76b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-02T01:00:13.933Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0649158..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/debug) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 56a418d..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/debug) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fbca1a7..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: '37 1 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -302,7 +299,7 @@ s1.end(); ## 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]. @@ -375,9 +372,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink +[@stdlib/streams/node/debug-sink]: https://github.com/stdlib-js/streams-node-debug-sink/tree/esm -[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect +[@stdlib/streams/node/inspect]: https://github.com/stdlib-js/streams-node-inspect/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.throughput.js b/benchmark/benchmark.throughput.js deleted file mode 100644 index 8aab626..0000000 --- a/benchmark/benchmark.throughput.js +++ /dev/null @@ -1,228 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils-noop' ); -var nextTick = require( '@stdlib/utils-next-tick' ); -var pkg = require( './../package.json' ).name; -var debugStream = 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', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable() { - WritableStream.call( this ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark' - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable() ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i.toString() ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); - -bench( pkg+'::throughput,object_mode,noop_callback', function benchmark( b ) { - var stream; - var opts; - var i; - - function Writable( opts ) { - WritableStream.call( this, opts ); - return this; - } - - inherit( Writable, WritableStream ); - Writable.prototype._write = onWrite; // eslint-disable-line no-underscore-dangle - - opts = { - 'name': 'throughput-benchmark', - 'objectMode': true - }; - stream = debugStream( opts, noop ); - stream.pipe( new Writable( opts ) ); - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return stream.write( i ); - } - b.toc(); - stream.end(); - - b.pass( 'benchmark finished' ); - b.end(); - } - - function onWrite( chunk, enc, clbk ) { - clbk(); // eslint-disable-line node/callback-return - next(); - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 51debb4..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/debug" -%% click B href "https://github.com/stdlib-js/streams-node-debug/tree/main" -%% click C href "https://github.com/stdlib-js/streams-node-debug/tree/production" -%% click D href "https://github.com/stdlib-js/streams-node-debug/tree/esm" -%% click E href "https://github.com/stdlib-js/streams-node-debug/tree/deno" -%% click F href "https://github.com/stdlib-js/streams-node-debug/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/debug -[production-url]: https://github.com/stdlib-js/streams-node-debug/tree/production -[deno-url]: https://github.com/stdlib-js/streams-node-debug/tree/deno -[deno-readme]: https://github.com/stdlib-js/streams-node-debug/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/streams-node-debug/tree/umd -[umd-readme]: https://github.com/stdlib-js/streams-node-debug/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/streams-node-debug/tree/esm -[esm-readme]: https://github.com/stdlib-js/streams-node-debug/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 1c7c5bf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import inspectStream from '../docs/types/index'; -export = inspectStream; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c33352d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var b=n(function(me,h){ -h.exports="debug-stream" -});var M=n(function(ge,O){ -var U=require("debug"),k=b(),z=U(k);O.exports=z -});var j=n(function(be,G){G.exports={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""}});var E=n(function(de,y){ -var K=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),d=require('@stdlib/assert-is-boolean/dist').isPrimitive,Q=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,X=require('@stdlib/assert-is-string/dist').isPrimitive,u=require('@stdlib/error-tools-fmtprodmsg/dist');function Y(e,r){return K(r)?o(r,"name")&&(e.name=r.name,!X(e.name))?new TypeError(u('1M52W',"name",e.name)):o(r,"objectMode")&&(e.objectMode=r.objectMode,!d(e.objectMode))?new TypeError(u('1M52o',"objectMode",e.objectMode)):o(r,"readableObjectMode")&&(e.readableObjectMode=r.readableObjectMode,!d(e.readableObjectMode))?new TypeError(u('1M52o',"readableObjectMode",e.readableObjectMode)):o(r,"allowHalfOpen")&&(e.allowHalfOpen=r.allowHalfOpen,!d(e.allowHalfOpen))?new TypeError(u('1M52o',"allowHalfOpen",e.allowHalfOpen)):o(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!Q(e.highWaterMark))?new TypeError(u('1M54k',"highWaterMark",e.highWaterMark)):null:new TypeError(u('1M52V',r));}y.exports=Y -});var S=n(function(ce,p){ -var Z=require("debug");p.exports=Z -});var g=n(function(we,N){ -var H=require('@stdlib/streams-node-inspect/dist'),T=require('@stdlib/assert-is-function/dist'),_=require('@stdlib/assert-is-buffer/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=require('@stdlib/utils-inherit/dist'),c=M(),ae=j(),x=b(),C=E(),ie=S();function l(e,r){var a,i,s,f,v;if(!(this instanceof l))return arguments.length>1?new l(e,r):arguments.length===1?new l(e):new l;if(a=ee({},ae),arguments.length>1){if(!T(r))throw new TypeError($('1M52b',r));v=r,f=C(a,e)}else arguments.length&&(T(e)?v=e:f=C(a,e));if(f)throw f;return a.name?i=x+":"+a.name:i=x,s=ie(i),c("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),H.call(this,a,L),this;function L(t,m){if(v)return c("Received a new chunk. Chunk: %s. Index: %d.",t.toString(),m),v(s,t,m);_(t)&&(t=t.toString()),t=JSON.stringify(t),c("Received a new chunk. Chunk: %s. Index: %d.",t,m),s("Chunk: %s. Index: %d.",t,m)}}re(l,H);N.exports=l -});var I=n(function(qe,F){ -var P=require('@stdlib/assert-is-function/dist'),V=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/error-tools-fmtprodmsg/dist'),W=require('@stdlib/object-assign/dist'),A=g();function te(e,r){var a,i;if(arguments.length>1){if(!V(e))throw new TypeError(w('1M52V',e));if(a=W({},e),i=r,!P(r))throw new TypeError(w('1M52b',r))}else if(arguments.length)if(P(e))a={},i=e;else{if(!V(e))throw new TypeError(w('1M52V',e));a=W({},e)}else a={};return a.objectMode=!0,i===void 0?new A(a):new A(a,i)}F.exports=te -});var D=n(function(he,B){ -var ne=require('@stdlib/assert-is-plain-object/dist'),ue=require('@stdlib/error-tools-fmtprodmsg/dist'),le=require('@stdlib/object-assign/dist'),R=g();function se(e){var r;if(arguments.length){if(!ne(e))throw new TypeError(ue('1M52V',e));r=le({},e)}else r={};return a;function a(i,s){return r.name=i,arguments.length>1?new R(r,s):new R(r)}}B.exports=se -});var J=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=g(),oe=I(),fe=D();J(q,"objectMode",oe);J(q,"factory",fe);module.exports=q; -/** @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 61e4435..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/namespace.js", "../lib/debug.js", "../lib/defaults.json", "../lib/validate.js", "../lib/logger.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// EXPORTS //\n\nmodule.exports = 'debug-stream';\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nvar NAMESPACE = require( './namespace.js' );\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "{\n\t\"objectMode\": false,\n\t\"allowHalfOpen\": false,\n\t\"readableObjectMode\": false,\n\t\"name\": \"\"\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\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, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'name', opts.name ) );\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, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'allowHalfOpen', opts.allowHalfOpen ) );\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\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 debug = require( 'debug' );\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 InspectStream = require( '@stdlib/streams-node-inspect' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar debug = require( './debug.js' );\nvar DEFAULTS = require( './defaults.json' );\nvar NAMESPACE = require( './namespace.js' );\nvar validate = require( './validate.js' );\nvar logger = require( './logger.js' );\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nmodule.exports = DebugStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\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\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( 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 debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = streamFactory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* var debugStream = require( '@stdlib/streams-node-debug' );\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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,cAsBAA,EAAO,QAAU,iBCtBjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAC1BC,EAAY,IAKZC,EAAQF,EAAQC,CAAU,EAK9BF,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,cAAiB,GACjB,mBAAsB,GACtB,KAAQ,EACT,ICLA,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,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAkB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMR,EAAUQ,CAAQ,EAGnBP,EAAYO,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG9GN,EAAYO,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACN,EAAWK,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HN,EAAYO,EAAS,oBAAqB,IAC9CD,EAAK,mBAAqBC,EAAQ,mBAC7B,CAACN,EAAWK,EAAK,kBAAmB,GACjC,IAAI,UAAWF,EAAQ,+DAAgE,qBAAsBE,EAAK,kBAAmB,CAAE,EAG3IN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAWK,EAAK,aAAc,GAC5B,IAAI,UAAWF,EAAQ,+DAAgE,gBAAiBE,EAAK,aAAc,CAAE,EAGjIN,EAAYO,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACL,EAAeI,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,EAG1I,KAhCC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAiChH,CAKAT,EAAO,QAAUO,ICrFjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,OAAQ,EAK7BD,EAAO,QAAUC,IC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,8BAA+B,EACxDC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAU,QAAS,uBAAwB,EAC3CC,EAAQ,IACRC,GAAW,IACXC,EAAY,IACZC,EAAW,IACXC,GAAS,IA8Bb,SAASC,EAAaC,EAASC,EAAO,CACrC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBP,GACtB,OAAK,UAAU,OAAS,EAChB,IAAIA,EAAaC,EAASC,CAAK,EAElC,UAAU,SAAW,EAClB,IAAIF,EAAaC,CAAQ,EAE1B,IAAID,EAGZ,GADAG,EAAOV,GAAQ,CAAC,EAAGG,EAAS,EACvB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACN,EAAYY,CAAK,EACtB,MAAM,IAAI,UAAWV,EAAQ,uEAAwEU,CAAK,CAAE,EAE7GK,EAAKL,EACLI,EAAMR,EAAUK,EAAMF,CAAQ,CAC/B,MAAY,UAAU,SAChBX,EAAYW,CAAQ,EACxBM,EAAKN,EAELK,EAAMR,EAAUK,EAAMF,CAAQ,GAGhC,GAAKK,EACJ,MAAMA,EAEP,OAAKH,EAAK,KACTC,EAAOP,EAAY,IAAMM,EAAK,KAE9BC,EAAOP,EAERQ,EAAMN,GAAQK,CAAK,EAEnBT,EAAO,yEAA0E,KAAK,UAAWQ,CAAK,CAAE,EACxGd,EAAc,KAAM,KAAMc,EAAMK,CAAQ,EAEjC,KAUP,SAASA,EAASC,EAAOC,EAAM,CAC9B,GAAKH,EACJ,OAAAZ,EAAO,8CAA+Cc,EAAM,SAAS,EAAGC,CAAI,EACrEH,EAAIF,EAAKI,EAAOC,CAAI,EAEvBnB,EAAUkB,CAAM,IACpBA,EAAQA,EAAM,SAAS,GAExBA,EAAQ,KAAK,UAAWA,CAAM,EAC9Bd,EAAO,8CAA+Cc,EAAOC,CAAI,EACjEL,EAAK,wBAAyBI,EAAOC,CAAI,CAC1C,CACD,CAKAhB,GAASM,EAAaX,CAAc,EAKpCD,EAAO,QAAUY,ICxIjB,IAAAW,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA6Bb,SAASC,GAAYC,EAASC,EAAO,CACpC,IAAIC,EACAC,EACJ,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACR,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAI9G,GAFAE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,EAC3BG,EAAKF,EACA,CAACP,EAAYO,CAAK,EACtB,MAAM,IAAI,UAAWL,EAAQ,uEAAwEK,CAAK,CAAE,CAE9G,SAAY,UAAU,OACrB,GAAKP,EAAYM,CAAQ,EACxBE,EAAO,CAAC,EACRC,EAAKH,MACC,CACN,GAAK,CAACL,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GE,EAAOL,EAAQ,CAAC,EAAGG,CAAQ,CAC5B,MAEAE,EAAO,CAAC,EAGT,OADAA,EAAK,WAAa,GACbC,IAAO,OACJ,IAAIL,EAAQI,CAAK,EAElB,IAAIJ,EAAQI,EAAMC,CAAG,CAC7B,CAKAV,EAAO,QAAUM,KC1FjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAW,QAAS,gCAAiC,EACrDC,GAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,EAAS,IA+Bb,SAASC,GAAeC,EAAU,CACjC,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,GAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,GAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAaC,EAAMC,EAAO,CAElC,OADAH,EAAK,KAAOE,EACP,UAAU,OAAS,EAChB,IAAIL,EAAQG,EAAMG,CAAK,EAExB,IAAIN,EAAQG,CAAK,CACzB,CACD,CAKAP,EAAO,QAAUK,KCpBjB,IAAIM,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_namespace", "__commonJSMin", "exports", "module", "require_debug", "__commonJSMin", "exports", "module", "logger", "NAMESPACE", "debug", "require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "format", "validate", "opts", "options", "require_logger", "__commonJSMin", "exports", "module", "debug", "require_main", "__commonJSMin", "exports", "module", "InspectStream", "isFunction", "isBuffer", "format", "assign", "inherit", "debug", "DEFAULTS", "NAMESPACE", "validate", "logger", "DebugStream", "options", "clbk", "opts", "name", "log", "err", "cb", "inspect", "chunk", "idx", "require_object_mode", "__commonJSMin", "exports", "module", "isFunction", "isObject", "format", "assign", "Stream", "objectMode", "options", "clbk", "opts", "cb", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "Stream", "streamFactory", "options", "opts", "debugStream", "name", "clbk", "setReadOnly", "main", "objectMode", "factory"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a15670e..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,128 +0,0 @@ - -{{alias}}( [options,] [clbk] ) - Returns a transform stream for debugging stream pipelines. - - If the `DEBUG` environment variable is not set, no data is logged. - - Providing a `name` option is *strongly* encouraged, as the `DEBUG` - environment variable can be used to filter debuggers. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream. - - Examples - -------- - > var s = {{alias}}( { 'name': 'foo' } ); - > s.write( 'a' ); - > s.write( 'b' ); - > s.write( 'c' ); - > s.end(); - - -{{alias}}.factory( [options] ) - Returns a function for creating transform streams for debugging stream - pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.objectMode: boolean (optional) - Specifies whether a stream should operate in "objectMode". Default: - false. - - options.highWaterMark: integer (optional) - Specifies the maximum number of bytes to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - Returns - ------- - createStream( name[, clbk] ): Function - Function for creating transform streams. - - Examples - -------- - > var opts = { 'objectMode': true, 'highWaterMark': 64 }; - > var createStream = {{alias}}.factory( opts ); - - -{{alias}}.objectMode( [options,] [clbk] ) - Returns an "objectMode" transform stream for debugging stream pipelines. - - Parameters - ---------- - options: Object (optional) - Options. - - options.name: string (optional) - Debug namespace. - - options.highWaterMark: integer (optional) - Specifies the maximum number of objects to store in an internal buffer - before ceasing to push downstream. - - options.allowHalfOpen: boolean (optional) - Specifies whether a stream should remain open even if one side ends. - Default: false. - - options.readableObjectMode: boolean (optional) - Specifies whether the readable side should be in "objectMode". Default: - false. - - clbk: Function (optional) - Callback to invoke upon receiving data. - - Returns - ------- - stream: TransformStream - Transform stream operating in "objectMode". - - Examples - -------- - > var s = {{alias}}.objectMode( { 'name': 'foo' } ); - > s.write( { 'value': 'a' } ); - > s.write( { 'value': 'b' } ); - > s.write( { 'value': 'c' } ); - > s.end(); - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a5b019f..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,152 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 DebugStream = require( './index' ); - -/** -* Callback function invoked upon receiving data. -* -* @param debug - logging function -* @param chunk - data chunk -* @param idx - chunk index -*/ -function clbk( debug: Function, chunk: any, idx: number ) { - debug( 'Received a new chunk...' ); - debug( 'Chunk: %s', chunk ); - debug( 'Index: %s', idx ); -} - - -// TESTS // - -// The constructor returns a stream... -{ - new DebugStream(); // $ExpectType Transform - new DebugStream( clbk ); // $ExpectType Transform - new DebugStream( { 'objectMode': true } ); // $ExpectType Transform - new DebugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor is callable... -{ - const debugStream = DebugStream; - debugStream(); // $ExpectType Transform - debugStream( clbk ); // $ExpectType Transform - debugStream( { 'objectMode': true } ); // $ExpectType Transform - debugStream( { 'objectMode': true }, clbk ); // $ExpectType Transform -} - -// The constructor has an `objectMode` method which returns a stream... -{ - DebugStream.objectMode(); // $ExpectType Transform - DebugStream.objectMode( clbk ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true } ); // $ExpectType Transform - DebugStream.objectMode( { 'allowHalfOpen': true }, clbk ); // $ExpectType Transform -} - -// The constructor has a `factory` method which returns a function for creating streams... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk ); // $ExpectType Transform - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk ); // $ExpectType Transform -} - -// The compiler throws an error if the constructor is provided a first argument which is not an options object or callback function... -{ - new DebugStream( 'abc', clbk ); // $ExpectError - new DebugStream( 123, clbk ); // $ExpectError - new DebugStream( true, clbk ); // $ExpectError - new DebugStream( false, clbk ); // $ExpectError - new DebugStream( [], clbk ); // $ExpectError - new DebugStream( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the constructor is provided a last argument which is not an options object or callback function... -{ - new DebugStream( {}, 'abc' ); // $ExpectError - new DebugStream( {}, 123 ); // $ExpectError - new DebugStream( {}, true ); // $ExpectError - new DebugStream( {}, false ); // $ExpectError - new DebugStream( {}, [] ); // $ExpectError - new DebugStream( {}, {} ); // $ExpectError - new DebugStream( {}, null ); // $ExpectError - - new DebugStream( 'abc' ); // $ExpectError - new DebugStream( 123 ); // $ExpectError - new DebugStream( true ); // $ExpectError - new DebugStream( false ); // $ExpectError - new DebugStream( [] ); // $ExpectError - new DebugStream( null ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a first argument which is not an options object or callback function... -{ - DebugStream.objectMode( 'abc', clbk ); // $ExpectError - DebugStream.objectMode( 123, clbk ); // $ExpectError - DebugStream.objectMode( true, clbk ); // $ExpectError - DebugStream.objectMode( false, clbk ); // $ExpectError - DebugStream.objectMode( [], clbk ); // $ExpectError - DebugStream.objectMode( null, clbk ); // $ExpectError -} - -// The compiler throws an error if the `objectMode` method is provided a last argument which is not an options object or callback function... -{ - DebugStream.objectMode( {}, 'abc' ); // $ExpectError - DebugStream.objectMode( {}, 123 ); // $ExpectError - DebugStream.objectMode( {}, true ); // $ExpectError - DebugStream.objectMode( {}, false ); // $ExpectError - DebugStream.objectMode( {}, [] ); // $ExpectError - DebugStream.objectMode( {}, {} ); // $ExpectError - DebugStream.objectMode( {}, null ); // $ExpectError - - DebugStream.objectMode( 'abc' ); // $ExpectError - DebugStream.objectMode( 123 ); // $ExpectError - DebugStream.objectMode( true ); // $ExpectError - DebugStream.objectMode( false ); // $ExpectError - DebugStream.objectMode( [] ); // $ExpectError - DebugStream.objectMode( null ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an argument which is not an options object... -{ - DebugStream.factory( 'abc' ); // $ExpectError - DebugStream.factory( 123 ); // $ExpectError - DebugStream.factory( true ); // $ExpectError - DebugStream.factory( false ); // $ExpectError - DebugStream.factory( [] ); // $ExpectError - DebugStream.factory( null ); // $ExpectError -} - -// The compiler throws an error if the function returned by the `factory` method is provided an invalid number of arguments... -{ - let f = DebugStream.factory(); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( {} ); - f( 'my-stream', clbk, clbk ); // $ExpectError - - f = DebugStream.factory( { 'objectMode': true } ); - f( 'my-stream', clbk, clbk ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 99b5d90..0000000 --- a/examples/index.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var parseJSON = require( '@stdlib/utils-parse-json' ); -var stdout = require( '@stdlib/streams-node-stdout' ); -var transformFactory = require( '@stdlib/streams-node-transform' ).factory; -var debug = require( './../lib' ).objectMode; - -function parse( chunk, enc, clbk ) { - clbk( null, parseJSON( chunk ) ); -} - -function pluck( chunk, enc, clbk ) { - clbk( null, chunk.value ); -} - -function square( chunk, enc, clbk ) { - var v = +chunk; - clbk( null, v*v ); -} - -function toStr( chunk, enc, clbk ) { - clbk( null, chunk.toString() ); -} - -function join( chunk, enc, clbk ) { - clbk( null, chunk+'\n' ); -} - -// Create a factory for generating streams running in `objectMode`: -var tStream = transformFactory({ - 'objectMode': true -}); - -// Create streams for each transform: -var s1 = tStream( parse ); -var d1 = debug({ - 'name': 'parse' -}); -var s2 = tStream( pluck ); -var d2 = debug({ - 'name': 'pluck' -}); -var s3 = tStream( square ); -var d3 = debug({ - 'name': 'square' -}); -var s4 = tStream( toStr ); -var d4 = debug({ - 'name': 'toString' -}); -var s5 = tStream( join ); -var d5 = debug({ - 'name': 'join' -}); - -// Create the pipeline: -s1.pipe( d1 ) - .pipe( s2 ) - .pipe( d2 ) - .pipe( s3 ) - .pipe( d3 ) - .pipe( s4 ) - .pipe( d4 ) - .pipe( s5 ) - .pipe( d5 ) - .pipe( stdout ); - -// Write data to the pipeline... -var v; -var i; -for ( i = 0; i < 100; i++ ) { - v = '{"value":'+i+'}'; - s1.write( v, 'utf8' ); -} -s1.end(); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c77e738 --- /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/streams-node-inspect@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/object-assign@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-inherit@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-plain-object@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-own-property@v0.2.2-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-boolean@v0.2.2-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-number@v0.2.2-esm/index.mjs";import{isPrimitive as m}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.2-esm/index.mjs";function h(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}var c=h(Object.freeze({__proto__:null,default:()=>()=>{}})),p="debug-stream",j=c(p),b={objectMode:!1,allowHalfOpen:!1,readableObjectMode:!1,name:""};function u(e,t){return a(t)?d(t,"name")&&(e.name=t.name,!m(e.name))?new TypeError(s("1M52W","name",e.name)):d(t,"objectMode")&&(e.objectMode=t.objectMode,!l(e.objectMode))?new TypeError(s("1M52o","objectMode",e.objectMode)):d(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!l(e.readableObjectMode))?new TypeError(s("1M52o","readableObjectMode",e.readableObjectMode)):d(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!l(e.allowHalfOpen))?new TypeError(s("1M52o","allowHalfOpen",e.allowHalfOpen)):d(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!f(e.highWaterMark))?new TypeError(s("1M54k","highWaterMark",e.highWaterMark)):null:new TypeError(s("1M52V",t))}var g=c;function v(e,i){var a,d,l,f,m;if(!(this instanceof v))return arguments.length>1?new v(e,i):1===arguments.length?new v(e):new v;if(a=o({},b),arguments.length>1){if(!r(i))throw new TypeError(s("1M52b",i));m=i,f=u(a,e)}else arguments.length&&(r(e)?m=e:f=u(a,e));if(f)throw f;return d=a.name?p+":"+a.name:p,l=g(d),j("Creating a transform stream configured with the following options: %s.",JSON.stringify(a)),t.call(this,a,(function(e,t){if(m)return j("Received a new chunk. Chunk: %s. Index: %d.",e.toString(),t),m(l,e,t);n(e)&&(e=e.toString());e=JSON.stringify(e),j("Received a new chunk. Chunk: %s. Index: %d.",e,t),l("Chunk: %s. Index: %d.",e,t)})),this}function w(e,t){var n,i;if(arguments.length>1){if(!a(e))throw new TypeError(s("1M52V",e));if(n=o({},e),i=t,!r(t))throw new TypeError(s("1M52b",t))}else if(arguments.length)if(r(e))n={},i=e;else{if(!a(e))throw new TypeError(s("1M52V",e));n=o({},e)}else n={};return n.objectMode=!0,void 0===i?new v(n):new v(n,i)}function M(e){var t;if(arguments.length){if(!a(e))throw new TypeError(s("1M52V",e));t=o({},e)}else t={};return function(e,r){if(t.name=e,arguments.length>1)return new v(t,r);return new v(t)}}i(v,t),e(v,"objectMode",w),e(v,"factory",M);export{v as default,M as factory,w as objectMode}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..db477c5 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/namespace.js","../lib/debug.js","../lib/validate.js","../lib/logger.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// EXPORTS //\n\nexport default 'debug-stream';\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See 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' );\nimport NAMESPACE from './namespace.js';\n\n\n// MAIN //\n\nvar debug = logger( NAMESPACE );\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 isObject from '@stdlib/assert-is-plain-object';\nimport hasOwnProp from '@stdlib/assert-has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert-is-boolean';\nimport { isPrimitive as isNonNegative } from '@stdlib/assert-is-nonnegative-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport 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.name] - debug namespace\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode\n* @returns {(Error|null)} null or an error object\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( '1M52V', options ) );\n\t}\n\tif ( hasOwnProp( options, 'name' ) ) {\n\t\topts.name = options.name;\n\t\tif ( !isString( opts.name ) ) {\n\t\t\treturn new TypeError( format( '1M52W', 'name', opts.name ) );\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( '1M52o', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'readableObjectMode' ) ) {\n\t\topts.readableObjectMode = options.readableObjectMode;\n\t\tif ( !isBoolean( opts.readableObjectMode ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'allowHalfOpen' ) ) {\n\t\topts.allowHalfOpen = options.allowHalfOpen;\n\t\tif ( !isBoolean( opts.allowHalfOpen ) ) {\n\t\t\treturn new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) );\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( '1M54k', 'highWaterMark', opts.highWaterMark ) );\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 debug = require( 'debug' );\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 InspectStream from '@stdlib/streams-node-inspect';\nimport isFunction from '@stdlib/assert-is-function';\nimport isBuffer from '@stdlib/assert-is-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport inherit from '@stdlib/utils-inherit';\nimport debug from './debug.js';\nimport DEFAULTS from './defaults.json';\nimport NAMESPACE from './namespace.js';\nimport validate from './validate.js';\nimport logger from './logger.js';\n\n\n// MAIN //\n\n/**\n* Debug stream constructor.\n*\n* @constructor\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = new DebugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*/\nfunction DebugStream( options, clbk ) {\n\tvar opts;\n\tvar name;\n\tvar log;\n\tvar err;\n\tvar cb;\n\tif ( !(this instanceof DebugStream) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new DebugStream( options, clbk );\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\treturn new DebugStream( options );\n\t\t}\n\t\treturn new DebugStream();\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t\tcb = clbk;\n\t\terr = validate( opts, options );\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\tcb = options;\n\t\t} else {\n\t\t\terr = validate( opts, options );\n\t\t}\n\t}\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( opts.name ) {\n\t\tname = NAMESPACE + ':' + opts.name;\n\t} else {\n\t\tname = NAMESPACE;\n\t}\n\tlog = logger( name );\n\n\tdebug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tInspectStream.call( this, opts, inspect );\n\n\treturn this;\n\n\t/**\n\t* Callback invoked upon receiving a new chunk.\n\t*\n\t* @private\n\t* @param {*} chunk - received chunk\n\t* @param {NonNegativeInteger} idx - chunk index\n\t* @returns {void}\n\t*/\n\tfunction inspect( chunk, idx ) {\n\t\tif ( cb ) {\n\t\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx );\n\t\t\treturn cb( log, chunk, idx );\n\t\t}\n\t\tif ( isBuffer( chunk ) ) {\n\t\t\tchunk = chunk.toString();\n\t\t}\n\t\tchunk = JSON.stringify( chunk );\n\t\tdebug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx );\n\t\tlog( 'Chunk: %s. Index: %d.', chunk, idx );\n\t}\n}\n\n/*\n* Inherit from the `InspectStream` prototype.\n*/\ninherit( DebugStream, InspectStream );\n\n\n// EXPORTS //\n\nexport default DebugStream;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert-is-function';\nimport isObject from '@stdlib/assert-is-plain-object';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport assign from '@stdlib/object-assign';\nimport Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Returns a debug stream with `objectMode` set to `true`.\n*\n* @param {Options} [options] - stream options\n* @param {string} [options.name] - debug namespace\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @param {Callback} [clbk] - callback to invoke upon receiving data\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} must provide a valid callback argument\n* @returns {DebugStream} debug stream\n*\n* @example\n* var stream = objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*/\nfunction objectMode( options, clbk ) {\n\tvar opts;\n\tvar cb;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t\tcb = clbk;\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( '1M52b', clbk ) );\n\t\t}\n\t} else if ( arguments.length ) {\n\t\tif ( isFunction( options ) ) {\n\t\t\topts = {};\n\t\t\tcb = options;\n\t\t} else {\n\t\t\tif ( !isObject( options ) ) {\n\t\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t\t}\n\t\t\topts = assign( {}, options );\n\t\t}\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\tif ( cb === void 0 ) {\n\t\treturn new Stream( opts );\n\t}\n\treturn new Stream( opts, cb );\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 Stream from './main.js';\n\n\n// MAIN //\n\n/**\n* Creates a reusable debug stream factory.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false`\n* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends\n* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode\n* @throws {TypeError} options argument must be an object\n* @returns {Function} debug stream factory\n*\n* @example\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = streamFactory( opts );\n*\n* // Assign each stream to a separate debug namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\n*/\nfunction streamFactory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( '1M52V', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn debugStream;\n\n\t/**\n\t* Creates a transform stream for debugging stream pipelines.\n\t*\n\t* @private\n\t* @param {string} name - debug namespace\n\t* @param {Callback} [clbk] - callback to invoke upon receiving data\n\t* @throws {TypeError} must provide valid options\n\t* @throws {TypeError} must provide a valid callback argument\n\t* @returns {DebugStream} debug stream\n\t*/\n\tfunction debugStream( name, clbk ) {\n\t\topts.name = name;\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new Stream( opts, clbk );\n\t\t}\n\t\treturn new Stream( opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default streamFactory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Transform stream for debugging stream pipelines.\n*\n* @module @stdlib/streams-node-debug\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( 'a' );\n* stream.write( 'b' );\n* stream.write( 'c' );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var stream = debugStream.objectMode({\n* 'name': 'my-stream'\n* });\n*\n* stream.write( {'value': 'a'} );\n* stream.write( {'value': 'b'} );\n* stream.write( {'value': 'c'} );\n* stream.end();\n*\n* @example\n* import debugStream from '@stdlib/streams-node-debug';\n*\n* var opts = {\n* 'objectMode': true,\n* 'highWaterMark': 64\n* };\n*\n* var factory = debugStream.factory( opts );\n*\n* // Assign each stream to a separate 'debug' namespace...\n* var streams = [];\n* var i;\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( factory( 'stream '+i ) );\n* }\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":["NAMESPACE","debug","require$$0","validate","opts","options","isObject","hasOwnProp","name","isString","TypeError","format","objectMode","isBoolean","readableObjectMode","allowHalfOpen","highWaterMark","isNonNegative","DebugStream","clbk","log","err","cb","this","arguments","length","assign","DEFAULTS","isFunction","logger","JSON","stringify","InspectStream","call","chunk","idx","toString","isBuffer","Stream","streamFactory","inherit","setReadOnly","main","factory"],"mappings":";;4qDAsBAA,EAAe,eCMXC,EANSC,EAMOF,oECiBpB,SAASG,EAAUC,EAAMC,GACxB,OAAMC,EAAUD,GAGXE,EAAYF,EAAS,UACzBD,EAAKI,KAAOH,EAAQG,MACdC,EAAUL,EAAKI,OACb,IAAIE,UAAWC,EAAQ,QAAS,OAAQP,EAAKI,OAGjDD,EAAYF,EAAS,gBACzBD,EAAKQ,WAAaP,EAAQO,YACpBC,EAAWT,EAAKQ,aACd,IAAIF,UAAWC,EAAQ,QAAS,aAAcP,EAAKQ,aAGvDL,EAAYF,EAAS,wBACzBD,EAAKU,mBAAqBT,EAAQS,oBAC5BD,EAAWT,EAAKU,qBACd,IAAIJ,UAAWC,EAAQ,QAAS,qBAAsBP,EAAKU,qBAG/DP,EAAYF,EAAS,mBACzBD,EAAKW,cAAgBV,EAAQU,eACvBF,EAAWT,EAAKW,gBACd,IAAIL,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKW,gBAG1DR,EAAYF,EAAS,mBACzBD,EAAKY,cAAgBX,EAAQW,eACvBC,EAAeb,EAAKY,gBAClB,IAAIN,UAAWC,EAAQ,QAAS,gBAAiBP,EAAKY,gBAGxD,KAhCC,IAAIN,UAAWC,EAAQ,QAASN,GAiCzC,CC1DA,IAAIJ,EAAQC,ECwCZ,SAASgB,EAAab,EAASc,GAC9B,IAAIf,EACAI,EACAY,EACAC,EACAC,EACJ,KAAOC,gBAAgBL,GACtB,OAAKM,UAAUC,OAAS,EAChB,IAAIP,EAAab,EAASc,GAER,IAArBK,UAAUC,OACP,IAAIP,EAAab,GAElB,IAAIa,EAGZ,GADAd,EAAOsB,EAAQ,GAAIC,GACdH,UAAUC,OAAS,EAAI,CAC3B,IAAMG,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,IAEvCG,EAAKH,EACLE,EAAMlB,EAAUC,EAAMC,EACxB,MAAamB,UAAUC,SAChBG,EAAYvB,GAChBiB,EAAKjB,EAELgB,EAAMlB,EAAUC,EAAMC,IAGxB,GAAKgB,EACJ,MAAMA,EAYP,OATCb,EADIJ,EAAKI,KACFR,EAAY,IAAMI,EAAKI,KAEvBR,EAERoB,EAAMS,EAAQrB,GAEdP,EAAO,yEAA0E6B,KAAKC,UAAW3B,IACjG4B,EAAcC,KAAMV,KAAMnB,GAY1B,SAAkB8B,EAAOC,GACxB,GAAKb,EAEJ,OADArB,EAAO,8CAA+CiC,EAAME,WAAYD,GACjEb,EAAIF,EAAKc,EAAOC,GAEnBE,EAAUH,KACdA,EAAQA,EAAME,YAEfF,EAAQJ,KAAKC,UAAWG,GACxBjC,EAAO,8CAA+CiC,EAAOC,GAC7Df,EAAK,wBAAyBc,EAAOC,EACrC,IArBMZ,IAsBR,CCvEA,SAASX,EAAYP,EAASc,GAC7B,IAAIf,EACAkB,EACJ,GAAKE,UAAUC,OAAS,EAAI,CAC3B,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAIvC,GAFAD,EAAOsB,EAAQ,GAAIrB,GACnBiB,EAAKH,GACCS,EAAYT,GACjB,MAAM,IAAIT,UAAWC,EAAQ,QAASQ,GAEzC,MAAQ,GAAKK,UAAUC,OACrB,GAAKG,EAAYvB,GAChBD,EAAO,CAAA,EACPkB,EAAKjB,MACC,CACN,IAAMC,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACnB,MAEDD,EAAO,CAAA,EAGR,OADAA,EAAKQ,YAAa,OACN,IAAPU,EACG,IAAIgB,EAAQlC,GAEb,IAAIkC,EAAQlC,EAAMkB,EAC1B,CC7BA,SAASiB,EAAelC,GACvB,IAAID,EACJ,GAAKoB,UAAUC,OAAS,CACvB,IAAMnB,EAAUD,GACf,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAEvCD,EAAOsB,EAAQ,GAAIrB,EACrB,MACED,EAAO,CAAA,EAER,OAYA,SAAsBI,EAAMW,GAE3B,GADAf,EAAKI,KAAOA,EACPgB,UAAUC,OAAS,EACvB,OAAO,IAAIa,EAAQlC,EAAMe,GAE1B,OAAO,IAAImB,EAAQlC,EACnB,CACF,CF8CAoC,EAAStB,EAAac,GGrDtBS,EAAAC,EAAA,aAAA9B,GACA6B,EAAAC,EAAA,UAAAC"} \ No newline at end of file diff --git a/lib/debug.js b/lib/debug.js deleted file mode 100644 index bd3e5b3..0000000 --- a/lib/debug.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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' ); -var NAMESPACE = require( './namespace.js' ); - - -// MAIN // - -var debug = logger( NAMESPACE ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index f8f5eca..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "objectMode": false, - "allowHalfOpen": false, - "readableObjectMode": false, - "name": "" -} diff --git a/lib/factory.js b/lib/factory.js deleted file mode 100644 index a98d587..0000000 --- a/lib/factory.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Stream = require( './main.js' ); - - -// MAIN // - -/** -* Creates a reusable debug stream factory. -* -* @param {Options} [options] - stream options -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @throws {TypeError} options argument must be an object -* @returns {Function} debug stream factory -* -* @example -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = streamFactory( opts ); -* -* // Assign each stream to a separate debug namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ -function streamFactory( options ) { - var opts; - if ( arguments.length ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } else { - opts = {}; - } - return debugStream; - - /** - * Creates a transform stream for debugging stream pipelines. - * - * @private - * @param {string} name - debug namespace - * @param {Callback} [clbk] - callback to invoke upon receiving data - * @throws {TypeError} must provide valid options - * @throws {TypeError} must provide a valid callback argument - * @returns {DebugStream} debug stream - */ - function debugStream( name, clbk ) { - opts.name = name; - if ( arguments.length > 1 ) { - return new Stream( opts, clbk ); - } - return new Stream( opts ); - } -} - - -// EXPORTS // - -module.exports = streamFactory; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 48b98ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform stream for debugging stream pipelines. -* -* @module @stdlib/streams-node-debug -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var stream = debugStream.objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -* -* @example -* var debugStream = require( '@stdlib/streams-node-debug' ); -* -* var opts = { -* 'objectMode': true, -* 'highWaterMark': 64 -* }; -* -* var factory = debugStream.factory( opts ); -* -* // Assign each stream to a separate 'debug' namespace... -* var streams = []; -* var i; -* for ( i = 0; i < 10; i++ ) { -* streams.push( factory( 'stream '+i ) ); -* } -*/ - - -// 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/logger.js b/lib/logger.js deleted file mode 100644 index e4a0132..0000000 --- a/lib/logger.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var debug = require( 'debug' ); - - -// EXPORTS // - -module.exports = debug; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d3a697..0000000 --- a/lib/main.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var InspectStream = require( '@stdlib/streams-node-inspect' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var inherit = require( '@stdlib/utils-inherit' ); -var debug = require( './debug.js' ); -var DEFAULTS = require( './defaults.json' ); -var NAMESPACE = require( './namespace.js' ); -var validate = require( './validate.js' ); -var logger = require( './logger.js' ); - - -// MAIN // - -/** -* Debug stream constructor. -* -* @constructor -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} must provide valid options -* @throws {TypeError} must a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = new DebugStream({ -* 'name': 'my-stream' -* }); -* -* stream.write( 'a' ); -* stream.write( 'b' ); -* stream.write( 'c' ); -* stream.end(); -*/ -function DebugStream( options, clbk ) { - var opts; - var name; - var log; - var err; - var cb; - if ( !(this instanceof DebugStream) ) { - if ( arguments.length > 1 ) { - return new DebugStream( options, clbk ); - } - if ( arguments.length === 1 ) { - return new DebugStream( options ); - } - return new DebugStream(); - } - opts = assign( {}, DEFAULTS ); - if ( arguments.length > 1 ) { - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - cb = clbk; - err = validate( opts, options ); - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - cb = options; - } else { - err = validate( opts, options ); - } - } - if ( err ) { - throw err; - } - if ( opts.name ) { - name = NAMESPACE + ':' + opts.name; - } else { - name = NAMESPACE; - } - log = logger( name ); - - debug( 'Creating a transform stream configured with the following options: %s.', JSON.stringify( opts ) ); - InspectStream.call( this, opts, inspect ); - - return this; - - /** - * Callback invoked upon receiving a new chunk. - * - * @private - * @param {*} chunk - received chunk - * @param {NonNegativeInteger} idx - chunk index - * @returns {void} - */ - function inspect( chunk, idx ) { - if ( cb ) { - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk.toString(), idx ); - return cb( log, chunk, idx ); - } - if ( isBuffer( chunk ) ) { - chunk = chunk.toString(); - } - chunk = JSON.stringify( chunk ); - debug( 'Received a new chunk. Chunk: %s. Index: %d.', chunk, idx ); - log( 'Chunk: %s. Index: %d.', chunk, idx ); - } -} - -/* -* Inherit from the `InspectStream` prototype. -*/ -inherit( DebugStream, InspectStream ); - - -// EXPORTS // - -module.exports = DebugStream; diff --git a/lib/namespace.js b/lib/namespace.js deleted file mode 100644 index 6c9f4ec..0000000 --- a/lib/namespace.js +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// EXPORTS // - -module.exports = 'debug-stream'; diff --git a/lib/object_mode.js b/lib/object_mode.js deleted file mode 100644 index 836a004..0000000 --- a/lib/object_mode.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isObject = require( '@stdlib/assert-is-plain-object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var assign = require( '@stdlib/object-assign' ); -var Stream = require( './main.js' ); - - -// MAIN // - -/** -* Returns a debug stream with `objectMode` set to `true`. -* -* @param {Options} [options] - stream options -* @param {string} [options.name] - debug namespace -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen=false] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode=false] - specifies whether the readable side should be in object mode -* @param {Callback} [clbk] - callback to invoke upon receiving data -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} must provide a valid callback argument -* @returns {DebugStream} debug stream -* -* @example -* var stream = objectMode({ -* 'name': 'my-stream' -* }); -* -* stream.write( {'value': 'a'} ); -* stream.write( {'value': 'b'} ); -* stream.write( {'value': 'c'} ); -* stream.end(); -*/ -function objectMode( options, clbk ) { - var opts; - var cb; - if ( arguments.length > 1 ) { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - cb = clbk; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( '1M52b', clbk ) ); - } - } else if ( arguments.length ) { - if ( isFunction( options ) ) { - opts = {}; - cb = options; - } else { - if ( !isObject( options ) ) { - throw new TypeError( format( '1M52V', options ) ); - } - opts = assign( {}, options ); - } - } else { - opts = {}; - } - opts.objectMode = true; - if ( cb === void 0 ) { - return new Stream( opts ); - } - return new Stream( opts, cb ); -} - - -// EXPORTS // - -module.exports = objectMode; diff --git a/lib/validate.js b/lib/validate.js deleted file mode 100644 index dc16c26..0000000 --- a/lib/validate.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 hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.name] - debug namespace -* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode -* @param {NonNegativeNumber} [options.highWaterMark] - specifies the `Buffer` level for when `write()` starts returning `false` -* @param {boolean} [options.allowHalfOpen] - specifies whether the stream should remain open even if one side ends -* @param {boolean} [options.readableObjectMode] - specifies whether the readable side should be in object mode -* @returns {(Error|null)} null or an error object -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( '1M52V', options ) ); - } - if ( hasOwnProp( options, 'name' ) ) { - opts.name = options.name; - if ( !isString( opts.name ) ) { - return new TypeError( format( '1M52W', 'name', opts.name ) ); - } - } - if ( hasOwnProp( options, 'objectMode' ) ) { - opts.objectMode = options.objectMode; - if ( !isBoolean( opts.objectMode ) ) { - return new TypeError( format( '1M52o', 'objectMode', opts.objectMode ) ); - } - } - if ( hasOwnProp( options, 'readableObjectMode' ) ) { - opts.readableObjectMode = options.readableObjectMode; - if ( !isBoolean( opts.readableObjectMode ) ) { - return new TypeError( format( '1M52o', 'readableObjectMode', opts.readableObjectMode ) ); - } - } - if ( hasOwnProp( options, 'allowHalfOpen' ) ) { - opts.allowHalfOpen = options.allowHalfOpen; - if ( !isBoolean( opts.allowHalfOpen ) ) { - return new TypeError( format( '1M52o', 'allowHalfOpen', opts.allowHalfOpen ) ); - } - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegative( opts.highWaterMark ) ) { - return new TypeError( format( '1M54k', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/package.json b/package.json index 9e48ad8..17bcde0 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform stream for debugging stream pipelines.", "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,50 +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-function": "^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/object-assign": "^0.2.2", - "@stdlib/streams-node-inspect": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-inherit": "^0.2.2", - "debug": "^2.6.9", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/buffer-from-string": "^0.2.2", - "@stdlib/streams-node-stdout": "^0.2.2", - "@stdlib/streams-node-transform": "^0.2.2", - "@stdlib/utils-next-tick": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "@stdlib/utils-parse-json": "^0.2.2", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2584f36 --- /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 f53fa10..0000000 --- a/test/test.factory.js +++ /dev/null @@ -1,146 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 throws an error if provided an options argument which is not an object', function test( t ) { - var createStream; - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream = factory( value ); - createStream( 'beep' ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided a callback argument which is not a function', function test( t ) { - var createStream; - var values; - var i; - - createStream = factory(); - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided '+values[i] ); - } - t.end(); - function badValue( value ) { - return function badValue() { - createStream( 'beep', value ); - }; - } -}); - -tape( 'the function returns a factory function which creates stream instances', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep' ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (callback)', function test( t ) { - var createStream; - var i; - - createStream = factory(); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns stream instances' ); - } - t.end(); -}); - -tape( 'the function returns a factory function which creates stream instances (options)', function test( t ) { - var createStream; - var i; - - createStream = factory({ - 'objectMode': true, - 'highWaterMark': 64, - 'allowHalfOpen': true - }); - - for ( i = 0; i < 10; i++ ) { - t.equal( createStream( 'beep', noop ) instanceof DebugStream, true, 'returns a stream instance' ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 6eba9e3..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 debugStream = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof debugStream, '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 debugStream.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 debugStream.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index a3fc2ef..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,339 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Transform = require( 'readable-stream' ).Transform; -var noop = require( '@stdlib/utils-noop' ); -var string2buffer = require( '@stdlib/buffer-from-string' ); -var NAMESPACE = require( './../lib/namespace.js' ); -var DebugStream = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof DebugStream, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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 s = new DebugStream( {}, value ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - }; - } -}); - -tape( 'the constructor throws an error if provided an invalid option (no callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor throws an error if provided an invalid option (w/ callback)', function test( t ) { - t.throws( foo, TypeError, 'throws a type error' ); - t.end(); - function foo() { - var s = new DebugStream({ - 'objectMode': 'beep' - }, noop ); - if ( s ) { - t.ok( false, 'did not throw' ); - } - } -}); - -tape( 'the constructor returns a Transform stream', function test( t ) { - var s = new DebugStream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` operator', function test( t ) { - var stream = DebugStream; - var s; - - s = stream(); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {} ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - s = stream( {}, noop ); - t.equal( s instanceof Transform, true, 'returns a Transform stream' ); - - t.end(); -}); - -tape( 'the constructor supports providing a debug namespace', function test( t ) { - var stream; - var opts; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - opts = { - 'name': 'beep' - }; - stream( opts ); - - function debug( name ) { - t.equal( name, NAMESPACE+':'+opts.name, 'uses provided debug namespace' ); - t.end(); - } -}); - -tape( 'the returned stream forwards streamed data to a logger', function test( t ) { - var expected; - var stream; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function debug() { - return function debug( data ) { - t.ok( data, 'logs data' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a logger (converts buffers to strings)', function test( t ) { - var stream; - var total; - var cnt; - var s; - - stream = proxyquire( './../lib/main.js', { - './logger.js': debug - }); - - s = stream(); - - total = 3; - cnt = 0; - - s.write( string2buffer( '1' ), 'utf8' ); - s.write( string2buffer( '2' ), 'utf8' ); - s.write( string2buffer( '3' ), 'utf8' ); - s.end(); - - function debug() { - return function debug( data ) { - t.equal( typeof data, 'string', 'logs data' ); - cnt += 1; - if ( cnt === total ) { - t.end(); - } - }; - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback', function test( t ) { - var expected; - var cnt; - var s; - - s = new DebugStream( onData ); - - expected = ['1', '2', '3']; - cnt = 0; - - s.write( '1' ); - s.write( '2' ); - s.write( '3' ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.equal( chunk.toString(), expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream forwards streamed data to a provided callback when in object mode', function test( t ) { - var expected; - var opts; - var cnt; - var s; - - opts = { - 'objectMode': true - }; - s = new DebugStream( opts, onData ); - - expected = [[1], [2], [3]]; - cnt = 0; - - s.write( [1] ); - s.write( [2] ); - s.write( [3] ); - s.end(); - - function onData( debug, chunk, idx ) { - t.equal( typeof debug, 'function', 'first argument is a function' ); - t.deepEqual( chunk, expected[ cnt ], 'streams expected chunk' ); - t.equal( idx, cnt, 'streams expected index' ); - cnt += 1; - if ( cnt === expected.length ) { - t.end(); - } - } -}); - -tape( 'the returned stream provides a method to destroy a stream', function test( t ) { - var count = 0; - var s; - - s = new DebugStream(); - - t.equal( typeof s.destroy, 'function', 'has destroy method' ); - - s.on( 'error', onError ); - s.on( 'close', onClose ); - - s.destroy( new Error() ); - - 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 = new DebugStream(); - - 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 ); - } -}); diff --git a/test/test.object_mode.js b/test/test.object_mode.js deleted file mode 100644 index b3cb328..0000000 --- a/test/test.object_mode.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 no-new-wrappers */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var DebugStream = 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 provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - void 0, - null, - NaN, - {}, - [] - ]; - - for ( i = 0; i < values.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( {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - [] - ]; - - for ( i = 0; i < values.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( value ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - void 0, - null, - NaN, - function noop() {}, - [] - ]; - - for ( i = 0; i < values.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( value, noop ); - }; - } -}); - -tape( 'the function returns a stream instance', function test( t ) { - var stream = objectMode(); - t.equal( stream instanceof DebugStream, true, 'returns a stream instance' ); - t.end(); -}); - -tape( 'the function returns a stream which allows writing objects', function test( t ) { - var stream; - var opts; - - stream = objectMode(); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - // Attempt to override should not work... - opts = { - // Option should be overridden... - 'objectMode': false - }; - - stream = objectMode( opts ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - stream = objectMode( opts, noop ); - stream.write( new String( 'beep' ) ); - stream.end(); - - t.ok( true, 'did not error when writing an object' ); - - t.end(); -}); diff --git a/test/test.validate.js b/test/test.validate.js deleted file mode 100644 index 906e59a..0000000 --- a/test/test.validate.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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, - true, - void 0, - null, - NaN, - 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 a `name` option which is not a string primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - true, - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'name': values[ i ] - }); - 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 `objectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - 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 `readableObjectMode` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'readableObjectMode': values[ i ] - }); - 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 `allowHalfOpen` option which is not a boolean primitive', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - '5', - void 0, - null, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'allowHalfOpen': values[ i ] - }); - t.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', - void 0, - null, - NaN, - [], - {}, - 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 null if all options are valid', function test( t ) { - var options; - var opts; - var err; - - options = { - 'name': 'beep', - 'objectMode': true, - 'readableObjectMode': true, - 'allowHalfOpen': true, - 'highWaterMark': 64 - }; - opts = {}; - err = validate( opts, options ); - - t.equal( err, null, 'returns null' ); - t.deepEqual( opts, options, 'sets option values' ); - - t.end(); -}); - -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(); -});