time-to-botec

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

index.js (2376B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2018 The Stdlib Authors.
      5 *
      6 * Licensed under the Apache License, Version 2.0 (the "License");
      7 * you may not use this file except in compliance with the License.
      8 * You may obtain a copy of the License at
      9 *
     10 *    http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing, software
     13 * distributed under the License is distributed on an "AS IS" BASIS,
     14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 * See the License for the specific language governing permissions and
     16 * limitations under the License.
     17 */
     18 
     19 'use strict';
     20 
     21 /**
     22 * Transform stream which inspects streamed data.
     23 *
     24 * @module @stdlib/streams/node/inspect
     25 *
     26 * @example
     27 * var inspectStream = require( '@stdlib/streams/node/inspect' );
     28 *
     29 * function log( chunk, idx ) {
     30 *     console.log( 'index: %d', idx );
     31 *     console.log( chunk );
     32 *     // => index: 0\na\nindex: 1\nb\nindex: 2\nc\n
     33 * }
     34 *
     35 * var stream = inspectStream( log );
     36 *
     37 * stream.write( 'a' );
     38 * stream.write( 'b' );
     39 * stream.write( 'c' );
     40 *
     41 * stream.end();
     42 *
     43 *
     44 * @example
     45 * var inspectStream = require( '@stdlib/streams/node/inspect' );
     46 *
     47 * function log( chunk, idx ) {
     48 *     console.log( 'index: %d', idx );
     49 *     console.log( chunk );
     50 *     // => index: 0\n{'value': 'a'}\nindex: 1\n{'value': 'b'}\nindex: 2\n{'value': 'c'}\n
     51 * }
     52 *
     53 * var stream = inspectStream.objectMode( log );
     54 *
     55 * stream.write( {'value': 'a'} );
     56 * stream.write( {'value': 'b'} );
     57 * stream.write( {'value': 'c'} );
     58 *
     59 * stream.end();
     60 *
     61 *
     62 * @example
     63 * var inspectStream = require( '@stdlib/streams/node/inspect' );
     64 *
     65 * function log( chunk, idx ) {
     66 *     console.log( 'index: %d', idx );
     67 *     console.log( chunk );
     68 * }
     69 *
     70 * var opts = {
     71 *     'objectMode': true,
     72 *     'highWaterMark': 64
     73 * };
     74 *
     75 * var factory = inspectStream.factory( opts );
     76 *
     77 * // Create 10 identically configured streams...
     78 * var streams = [];
     79 * var i;
     80 * for ( i = 0; i < 10; i++ ) {
     81 *     streams.push( factory( log ) );
     82 * }
     83 */
     84 
     85 
     86 // MODULES //
     87 
     88 var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
     89 var stream = require( './main.js' );
     90 var objectMode = require( './object_mode.js' );
     91 var factory = require( './factory.js' );
     92 
     93 
     94 // MAIN //
     95 
     96 setReadOnly( stream, 'objectMode', objectMode );
     97 setReadOnly( stream, 'factory', factory );
     98 
     99 
    100 // EXPORTS //
    101 
    102 module.exports = stream;