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