time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3871B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Empty Stream
     22 
     23 > Create an "empty" [readable stream][readable-stream].
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var emptyStream = require( '@stdlib/streams/node/empty' );
     31 ```
     32 
     33 <a name="empty-stream"></a>
     34 
     35 #### emptyStream( \[options] )
     36 
     37 Returns an "empty" [readable stream][readable-stream] (i.e., a [stream][stream] which never streams any values).
     38 
     39 ```javascript
     40 var inspectStream = require( '@stdlib/streams/node/inspect-sink' );
     41 
     42 function log( chunk ) {
     43     // This function should never be called...
     44     console.log( chunk.toString() );
     45 }
     46 
     47 var stream = emptyStream();
     48 var iStream = inspectStream( log );
     49 
     50 stream.pipe( iStream );
     51 ```
     52 
     53 The function accepts the following `options`:
     54 
     55 -   **objectMode**: specifies whether a [stream][stream] should operate in [objectMode][object-mode]. Default: `false`.
     56 
     57 To set [stream][stream] `options`,
     58 
     59 ```javascript
     60 var opts = {
     61     'objectMode': true
     62 };
     63 
     64 var stream = emptyStream( opts );
     65 ```
     66 
     67 * * *
     68 
     69 #### emptyStream.factory( \[options] )
     70 
     71 Returns a `function` for creating "empty" [readable streams][readable-stream].
     72 
     73 ```javascript
     74 var opts = {
     75     'objectMode': true
     76 };
     77 
     78 var createStream = emptyStream.factory( opts );
     79 
     80 var stream1 = createStream();
     81 var stream2 = createStream();
     82 // ...
     83 ```
     84 
     85 The method accepts the same `options` as [`emptyStream()`](#empty-stream).
     86 
     87 * * *
     88 
     89 #### emptyStream.objectMode()
     90 
     91 This method is a convenience function to create "empty" [streams][stream] which **always** operate in [objectMode][object-mode].
     92 
     93 ```javascript
     94 var inspectStream = require( '@stdlib/streams/node/inspect-sink' );
     95 
     96 function log( v ) {
     97     console.log( v );
     98 }
     99 
    100 var stream = emptyStream.objectMode();
    101 
    102 var opts = {
    103     'objectMode': true
    104 };
    105 var iStream = inspectStream( opts, log );
    106 
    107 stream.pipe( iStream );
    108 ```
    109 
    110 </section>
    111 
    112 <!-- /.usage -->
    113 
    114 <section class="notes">
    115 
    116 </section>
    117 
    118 <!-- /.notes -->
    119 
    120 * * *
    121 
    122 <section class="examples">
    123 
    124 ## Examples
    125 
    126 <!-- eslint no-undef: "error" -->
    127 
    128 ```javascript
    129 var inspectStream = require( '@stdlib/streams/node/inspect-sink' );
    130 var emptyStream = require( '@stdlib/streams/node/empty' );
    131 
    132 function log( v ) {
    133     console.log( v.toString() );
    134 }
    135 
    136 var opts = {
    137     'objectMode': true
    138 };
    139 var stream = emptyStream( opts );
    140 
    141 opts = {
    142     'objectMode': true
    143 };
    144 var iStream = inspectStream( opts, log );
    145 
    146 stream.pipe( iStream );
    147 ```
    148 
    149 </section>
    150 
    151 <!-- /.examples -->
    152 
    153 <!-- Section for describing a command-line interface. -->
    154 
    155 * * *
    156 
    157 <section class="cli">
    158 
    159 ## CLI
    160 
    161 <!-- CLI usage documentation. -->
    162 
    163 <section class="usage">
    164 
    165 ### Usage
    166 
    167 ```text
    168 Usage: empty-stream [options]
    169 
    170 Options:
    171 
    172   -h,  --help               Print this message.
    173   -V,  --version            Print the package version.
    174 ```
    175 
    176 </section>
    177 
    178 <!-- /.usage -->
    179 
    180 <!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    181 
    182 <section class="notes">
    183 
    184 </section>
    185 
    186 <!-- /.notes -->
    187 
    188 <!-- CLI usage examples. -->
    189 
    190 <section class="examples">
    191 
    192 ### Examples
    193 
    194 ```bash
    195 $ empty-stream
    196 ```
    197 
    198 </section>
    199 
    200 <!-- /.examples -->
    201 
    202 </section>
    203 
    204 <!-- /.cli -->
    205 
    206 <section class="links">
    207 
    208 [stream]: https://nodejs.org/api/stream.html
    209 
    210 [object-mode]: https://nodejs.org/api/stream.html#stream_object_mode
    211 
    212 [readable-stream]: https://nodejs.org/api/stream.html
    213 
    214 </section>
    215 
    216 <!-- /.links -->