repl.txt (8471B)
1 2 {{alias}}( [options] ) 3 Returns a readable stream for generating pseudorandom numbers having integer 4 values. 5 6 In addition to standard readable stream events, the returned stream emits a 7 'state' event after internally generating `siter` pseudorandom numbers, 8 which is useful when wanting to deterministically capture a stream's 9 underlying PRNG state. 10 11 The default underlying pseudorandom number generator (PRNG) *may* change in 12 the future. If exact reproducibility is required, either explicitly specify 13 a PRNG via the `name` option or use an underlying PRNG directly. 14 15 Parameters 16 ---------- 17 options: Object (optional) 18 Options. 19 20 options.objectMode: boolean (optional) 21 Specifies whether a stream should operate in "objectMode". Default: 22 false. 23 24 options.encoding: string|null (optional) 25 Specifies how Buffer objects should be decoded to strings. Default: 26 null. 27 28 options.highWaterMark: integer (optional) 29 Specifies the maximum number of bytes to store in an internal buffer 30 before ceasing to generate additional pseudorandom numbers. 31 32 options.sep: string (optional) 33 Separator used to join streamed data. This option is only applicable 34 when a stream is not in "objectMode". Default: '\n'. 35 36 options.iter: integer (optional) 37 Number of iterations. 38 39 options.name: string (optional) 40 Name of a supported pseudorandom number generator (PRNG), which will 41 serve as the underlying source of pseudorandom numbers. The following 42 PRNGs are supported: 43 44 - mt19937: 32-bit Mersenne Twister. 45 - minstd: linear congruential PRNG based on Park and Miller. 46 - minstd-shuffle: linear congruential PRNG whose output is shuffled. 47 48 Default: 'mt19937'. 49 50 options.seed: any (optional) 51 Pseudorandom number generator seed. Valid seed values vary according to 52 the underlying PRNG. 53 54 options.state: any (optional) 55 Pseudorandom number generator state. Valid state values vary according 56 to the underling PRNG. If provided, the `seed` option is ignored. 57 58 options.copy: boolean (optional) 59 Boolean indicating whether to copy a provided pseudorandom number 60 generator state. Setting this option to `false` allows sharing state 61 between two or more pseudorandom number generators. Setting this option 62 to `true` ensures that a returned iterator has exclusive control over 63 its internal state. Default: true. 64 65 options.siter: integer (optional) 66 Number of iterations after which to emit the PRNG state. Default: 1e308. 67 68 Returns 69 ------- 70 stream: ReadableStream 71 Readable stream. 72 73 stream.PRNG: Function 74 Underlying pseudorandom number generator. 75 76 stream.seed: any 77 Pseudorandom number generator seed. 78 79 stream.seedLength: integer 80 Length of generator seed. 81 82 stream.state: any 83 Generator state. 84 85 stream.stateLength: integer 86 Length of generator state. 87 88 stream.byteLength: integer 89 Size (in bytes) of generator state. 90 91 Examples 92 -------- 93 > function fcn( chunk ) { console.log( chunk.toString() ); }; 94 > var opts = { 'iter': 10 }; 95 > var s = {{alias}}( opts ); 96 > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); 97 > s.pipe( o ); 98 99 100 {{alias}}.factory( [options] ) 101 Returns a function for creating readable streams which generate pseudorandom 102 numbers having integer values. 103 104 Parameters 105 ---------- 106 options.objectMode: boolean (optional) 107 Specifies whether a stream should operate in "objectMode". Default: 108 false. 109 110 options.encoding: string|null (optional) 111 Specifies how Buffer objects should be decoded to strings. Default: 112 null. 113 114 options.highWaterMark: integer (optional) 115 Specifies the maximum number of bytes to store in an internal buffer 116 before ceasing to generate additional pseudorandom numbers. 117 118 options.sep: string (optional) 119 Separator used to join streamed data. This option is only applicable 120 when a stream is not in "objectMode". Default: '\n'. 121 122 options.iter: integer (optional) 123 Number of iterations. 124 125 options.name: string (optional) 126 Name of a supported pseudorandom number generator (PRNG), which will 127 serve as the underlying source of pseudorandom numbers. The following 128 PRNGs are supported: 129 130 - mt19937: 32-bit Mersenne Twister. 131 - minstd: linear congruential PRNG based on Park and Miller. 132 - minstd-shuffle: linear congruential PRNG whose output is shuffled. 133 134 Default: 'mt19937'. 135 136 options.seed: any (optional) 137 Pseudorandom number generator seed. Valid seed values vary according to 138 the underlying PRNG. 139 140 options.state: any (optional) 141 Pseudorandom number generator state. Valid state values vary according 142 to the underling PRNG. If provided, the `seed` option is ignored. 143 144 options.copy: boolean (optional) 145 Boolean indicating whether to copy a provided pseudorandom number 146 generator state. Setting this option to `false` allows sharing state 147 between two or more pseudorandom number generators. Setting this option 148 to `true` ensures that a returned iterator has exclusive control over 149 its internal state. Default: true. 150 151 options.siter: integer (optional) 152 Number of iterations after which to emit the PRNG state. Default: 1e308. 153 154 Returns 155 ------- 156 fcn: Function 157 Function for creating readable streams. 158 159 Examples 160 -------- 161 > var opts = { 'objectMode': true, 'highWaterMark': 64 }; 162 > var createStream = {{alias}}.factory( opts ); 163 164 165 {{alias}}.objectMode( [options] ) 166 Returns an "objectMode" readable stream for generating pseudorandom numbers 167 having integer values. 168 169 Parameters 170 ---------- 171 options: Object (optional) 172 Options. 173 174 options.encoding: string|null (optional) 175 Specifies how Buffer objects should be decoded to strings. Default: 176 null. 177 178 options.highWaterMark: integer (optional) 179 Specifies the maximum number of objects to store in an internal buffer 180 before ceasing to generate additional pseudorandom numbers. 181 182 options.iter: integer (optional) 183 Number of iterations. 184 185 options.name: string (optional) 186 Name of a supported pseudorandom number generator (PRNG), which will 187 serve as the underlying source of pseudorandom numbers. The following 188 PRNGs are supported: 189 190 - mt19937: 32-bit Mersenne Twister. 191 - minstd: linear congruential PRNG based on Park and Miller. 192 - minstd-shuffle: linear congruential PRNG whose output is shuffled. 193 194 Default: 'mt19937'. 195 196 options.seed: any (optional) 197 Pseudorandom number generator seed. Valid seed values vary according to 198 the underlying PRNG. 199 200 options.state: any (optional) 201 Pseudorandom number generator state. Valid state values vary according 202 to the underling PRNG. If provided, the `seed` option is ignored. 203 204 options.copy: boolean (optional) 205 Boolean indicating whether to copy a provided pseudorandom number 206 generator state. Setting this option to `false` allows sharing state 207 between two or more pseudorandom number generators. Setting this option 208 to `true` ensures that a returned iterator has exclusive control over 209 its internal state. Default: true. 210 211 options.siter: integer (optional) 212 Number of iterations after which to emit the PRNG state. Default: 1e308. 213 214 Returns 215 ------- 216 stream: ReadableStream 217 Readable stream operating in "objectMode". 218 219 stream.PRNG: Function 220 Underlying pseudorandom number generator. 221 222 stream.seed: any 223 Pseudorandom number generator seed. 224 225 stream.seedLength: integer 226 Length of generator seed. 227 228 stream.state: any 229 Generator state. 230 231 stream.stateLength: integer 232 Length of generator state. 233 234 stream.byteLength: integer 235 Size (in bytes) of generator state. 236 237 Examples 238 -------- 239 > function fcn( v ) { console.log( v ); }; 240 > var opts = { 'iter': 10 }; 241 > var s = {{alias}}.objectMode( opts ); 242 > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); 243 > s.pipe( o ); 244 245 See Also 246 -------- 247