repl.txt (8172B)
1 2 {{alias}}( [options] ) 3 Returns a readable stream for generating pseudorandom numbers on the 4 interval `[1, 2147483646]`. 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 underlying pseudorandom number generator (PRNG) is a linear congruential 12 pseudorandom number generator (LCG) based on Park and Miller. 13 14 The generator has a period of approximately `2.1e9`. 15 16 An LCG is fast and uses little memory. On the other hand, because the 17 generator is a simple LCG, the generator has recognized shortcomings. By 18 today's PRNG standards, the generator's period is relatively short. More 19 importantly, the "randomness quality" of the generator's output is lacking. 20 These defects make the generator unsuitable, for example, in Monte Carlo 21 simulations and in cryptographic applications. 22 23 Parameters 24 ---------- 25 options: Object (optional) 26 Options. 27 28 options.objectMode: boolean (optional) 29 Specifies whether a stream should operate in "objectMode". Default: 30 false. 31 32 options.encoding: string|null (optional) 33 Specifies how Buffer objects should be decoded to strings. Default: 34 null. 35 36 options.highWaterMark: integer (optional) 37 Specifies the maximum number of bytes to store in an internal buffer 38 before ceasing to generate additional pseudorandom numbers. 39 40 options.sep: string (optional) 41 Separator used to join streamed data. This option is only applicable 42 when a stream is not in "objectMode". Default: '\n'. 43 44 options.iter: integer (optional) 45 Number of iterations. 46 47 options.normalized: boolean (optional) 48 Boolean indicating whether to return pseudorandom numbers on the 49 interval `[0,1)`. 50 51 options.seed: integer|ArrayLikeObject<integer> (optional) 52 Pseudorandom number generator seed. The seed may be either a positive 53 signed 32-bit integer or, for arbitrary length seeds, an array-like 54 object containing signed 32-bit integers. 55 56 options.state: Int32Array (optional) 57 Pseudorandom number generator state. If provided, the `seed` option is 58 ignored. 59 60 options.copy: boolean (optional) 61 Boolean indicating whether to copy a provided pseudorandom number 62 generator state. Setting this option to `false` allows sharing state 63 between two or more pseudorandom number generators. Setting this option 64 to `true` ensures that a returned iterator has exclusive control over 65 its internal state. Default: true. 66 67 options.siter: integer (optional) 68 Number of iterations after which to emit the PRNG state. Default: 1e308. 69 70 Returns 71 ------- 72 stream: ReadableStream 73 Readable stream. 74 75 stream.seed: Int32Array|null 76 Pseudorandom number generator seed. 77 78 stream.seedLength: integer|null 79 Length of generator seed. 80 81 stream.state: Int32Array|null 82 Generator state. 83 84 stream.stateLength: integer|null 85 Length of generator state. 86 87 stream.byteLength: integer|null 88 Size (in bytes) of generator state. 89 90 Examples 91 -------- 92 > function fcn( chunk ) { console.log( chunk.toString() ); }; 93 > var opts = { 'iter': 10 }; 94 > var s = {{alias}}( opts ); 95 > var o = {{alias:@stdlib/streams/node/inspect-sink}}( fcn ); 96 > s.pipe( o ); 97 98 99 {{alias}}.factory( [options] ) 100 Returns a function for creating readable streams which generate pseudorandom 101 numbers on the interval `[1, 2147483646]`. 102 103 Parameters 104 ---------- 105 options.objectMode: boolean (optional) 106 Specifies whether a stream should operate in "objectMode". Default: 107 false. 108 109 options.encoding: string|null (optional) 110 Specifies how Buffer objects should be decoded to strings. Default: 111 null. 112 113 options.highWaterMark: integer (optional) 114 Specifies the maximum number of bytes to store in an internal buffer 115 before ceasing to generate additional pseudorandom numbers. 116 117 options.sep: string (optional) 118 Separator used to join streamed data. This option is only applicable 119 when a stream is not in "objectMode". Default: '\n'. 120 121 options.iter: integer (optional) 122 Number of iterations. 123 124 options.normalized: boolean (optional) 125 Boolean indicating whether to return pseudorandom numbers on the 126 interval `[0,1)`. 127 128 options.seed: integer|ArrayLikeObject<integer> (optional) 129 Pseudorandom number generator seed. The seed may be either a positive 130 signed 32-bit integer or, for arbitrary length seeds, an array-like 131 object containing signed 32-bit integers. 132 133 options.state: Int32Array (optional) 134 Pseudorandom number generator state. If provided, the `seed` option is 135 ignored. 136 137 options.copy: boolean (optional) 138 Boolean indicating whether to copy a provided pseudorandom number 139 generator state. Setting this option to `false` allows sharing state 140 between two or more pseudorandom number generators. Setting this option 141 to `true` ensures that a returned iterator has exclusive control over 142 its internal state. Default: true. 143 144 options.siter: integer (optional) 145 Number of iterations after which to emit the PRNG state. Default: 1e308. 146 147 Returns 148 ------- 149 fcn: Function 150 Function for creating readable streams. 151 152 Examples 153 -------- 154 > var opts = { 'objectMode': true, 'highWaterMark': 64 }; 155 > var createStream = {{alias}}.factory( opts ); 156 157 158 {{alias}}.objectMode( [options] ) 159 Returns an "objectMode" readable stream for generating pseudorandom numbers 160 on the interval `[1, 2147483646]`. 161 162 Parameters 163 ---------- 164 options: Object (optional) 165 Options. 166 167 options.encoding: string|null (optional) 168 Specifies how Buffer objects should be decoded to strings. Default: 169 null. 170 171 options.highWaterMark: integer (optional) 172 Specifies the maximum number of objects to store in an internal buffer 173 before ceasing to generate additional pseudorandom numbers. 174 175 options.iter: integer (optional) 176 Number of iterations. 177 178 options.normalized: boolean (optional) 179 Boolean indicating whether to return pseudorandom numbers on the 180 interval `[0,1)`. 181 182 options.seed: integer|ArrayLikeObject<integer> (optional) 183 Pseudorandom number generator seed. The seed may be either a positive 184 signed 32-bit integer or, for arbitrary length seeds, an array-like 185 object containing signed 32-bit integers. 186 187 options.state: Int32Array (optional) 188 Pseudorandom number generator state. If provided, the `seed` option is 189 ignored. 190 191 options.copy: boolean (optional) 192 Boolean indicating whether to copy a provided pseudorandom number 193 generator state. Setting this option to `false` allows sharing state 194 between two or more pseudorandom number generators. Setting this option 195 to `true` ensures that a returned iterator has exclusive control over 196 its internal state. Default: true. 197 198 options.siter: integer (optional) 199 Number of iterations after which to emit the PRNG state. Default: 1e308. 200 201 Returns 202 ------- 203 stream: ReadableStream 204 Readable stream operating in "objectMode". 205 206 stream.seed: Int32Array|null 207 Pseudorandom number generator seed. 208 209 stream.seedLength: integer|null 210 Length of generator seed. 211 212 stream.state: Int32Array|null 213 Generator state. 214 215 stream.stateLength: integer|null 216 Length of generator state. 217 218 stream.byteLength: integer|null 219 Size (in bytes) of generator state. 220 221 Examples 222 -------- 223 > function fcn( v ) { console.log( v ); }; 224 > var opts = { 'iter': 10 }; 225 > var s = {{alias}}.objectMode( opts ); 226 > var o = {{alias:@stdlib/streams/node/inspect-sink}}.objectMode( fcn ); 227 > s.pipe( o ); 228 229 See Also 230 -------- 231