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