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