repl.txt (4733B)
1 2 {{alias}}( N, buffer, stride, offset[, options] ) 3 Creates a readable stream from a strided array-like object. 4 5 In object mode, `null` is a reserved value. If an array contains `null` 6 values (e.g., as a means to encode missing values), the stream will 7 prematurely end. Consider an alternative encoding or filter `null` values 8 prior to invocation. 9 10 In binary mode, if an array contains `undefined` values, the stream will 11 emit an error. Consider providing a custom serialization function or 12 filtering `undefined` values prior to invocation. 13 14 If a serialization function fails to return a string or Buffer, the stream 15 emits an error. 16 17 Parameters 18 ---------- 19 N: integer 20 Number of values to stream. 21 22 buffer: ArrayLikeObject 23 Array-like object from which to create the stream. 24 25 stride: integer 26 Stride length. 27 28 offset: integer 29 Starting index. 30 31 options: Object (optional) 32 Options. 33 34 options.objectMode: boolean (optional) 35 Specifies whether a stream should operate in "objectMode". Default: 36 false. 37 38 options.encoding: string|null (optional) 39 Specifies how Buffer objects should be decoded to strings. Default: 40 null. 41 42 options.highWaterMark: integer (optional) 43 Specifies the maximum number of bytes to store in an internal buffer 44 before pausing the stream. 45 46 options.sep: string (optional) 47 Separator used to join streamed data. This option is only applicable 48 when a stream is not in "objectMode". Default: '\n'. 49 50 options.serialize: Function (optional) 51 Serialization function. The default behavior is to serialize streamed 52 values as JSON strings. This option is only applicable when a stream is 53 not in "objectMode". 54 55 Returns 56 ------- 57 stream: ReadableStream 58 Readable stream. 59 60 Examples 61 -------- 62 > function fcn( chunk ) { console.log( chunk.toString() ); }; 63 > var s = {{alias}}( 3, [ 1, 2, 3 ], 1, 0 ); 64 > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); 65 > s.pipe( o ); 66 67 68 {{alias}}.factory( [options] ) 69 Returns a function for creating readable streams from array-like objects. 70 71 Parameters 72 ---------- 73 options: Object (optional) 74 Options. 75 76 options.objectMode: boolean (optional) 77 Specifies whether a stream should operate in "objectMode". Default: 78 false. 79 80 options.encoding: string|null (optional) 81 Specifies how Buffer objects should be decoded to strings. Default: 82 null. 83 84 options.highWaterMark: integer (optional) 85 Specifies the maximum number of bytes to store in an internal buffer 86 before pausing streaming. 87 88 options.sep: string (optional) 89 Separator used to join streamed data. This option is only applicable 90 when a stream is not in "objectMode". Default: '\n'. 91 92 options.serialize: Function (optional) 93 Serialization function. The default behavior is to serialize streamed 94 values as JSON strings. This option is only applicable when a stream is 95 not in "objectMode". 96 97 Returns 98 ------- 99 fcn: Function 100 Function for creating readable streams. 101 102 Examples 103 -------- 104 > var opts = { 'objectMode': true, 'highWaterMark': 64 }; 105 > var createStream = {{alias}}.factory( opts ); 106 107 108 {{alias}}.objectMode( N, buffer, stride, offset[, options] ) 109 Returns an "objectMode" readable stream from a strided array-like object. 110 111 In object mode, `null` is a reserved value. If an array contains `null` 112 values (e.g., as a means to encode missing values), the stream will 113 prematurely end. Consider an alternative encoding or filter `null` values 114 prior to invocation. 115 116 Parameters 117 ---------- 118 N: integer 119 Number of values to stream. 120 121 buffer: ArrayLikeObject 122 Array-like object from which to create the stream. 123 124 stride: integer 125 Stride length. 126 127 offset: integer 128 Starting index. 129 130 options: Object (optional) 131 Options. 132 133 options.encoding: string|null (optional) 134 Specifies how Buffer objects should be decoded to strings. Default: 135 null. 136 137 options.highWaterMark: integer (optional) 138 Specifies the maximum number of objects to store in an internal buffer 139 before pausing streaming. 140 141 Returns 142 ------- 143 stream: ReadableStream 144 Readable stream operating in "objectMode". 145 146 Examples 147 -------- 148 > function fcn( v ) { console.log( v ); }; 149 > var s = {{alias}}.objectMode( 3, [ 1, 2, 3 ], 1, 0 ); 150 > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); 151 > s.pipe( o ); 152 153 See Also 154 -------- 155