repl.txt (2833B)
1 2 {{alias}}( [options] ) 3 Returns an iterator for generating pseudorandom integers on the interval 4 `[1, 2147483646]`. 5 6 If an environment supports Symbol.iterator, the returned iterator is 7 iterable. 8 9 This pseudorandom number generator (PRNG) is a linear congruential 10 pseudorandom number generator (LCG) based on Park and Miller. 11 12 The generator has a period of approximately `2.1e9`. 13 14 An LCG is fast and uses little memory. On the other hand, because the 15 generator is a simple LCG, the generator has recognized shortcomings. By 16 today's PRNG standards, the generator's period is relatively short. More 17 importantly, the "randomness quality" of the generator's output is lacking. 18 These defects make the generator unsuitable, for example, in Monte Carlo 19 simulations and in cryptographic applications. 20 21 Parameters 22 ---------- 23 options: Object (optional) 24 Options. 25 26 options.normalized: boolean (optional) 27 Boolean indicating whether to return pseudorandom numbers on the 28 interval `[0,1)`. 29 30 options.seed: integer|ArrayLikeObject<integer> (optional) 31 Pseudorandom number generator seed. The seed may be either a positive 32 signed 32-bit integer or, for arbitrary length seeds, an array-like 33 object containing positive signed 32-bit integers. 34 35 options.state: Int32Array (optional) 36 Pseudorandom number generator state. If provided, the `seed` option is 37 ignored. 38 39 options.copy: boolean (optional) 40 Boolean indicating whether to copy a provided pseudorandom number 41 generator state. Setting this option to `false` allows sharing state 42 between two or more pseudorandom number generators. Setting this option 43 to `true` ensures that a returned iterator has exclusive control over 44 its internal state. Default: true. 45 46 options.iter: integer (optional) 47 Number of iterations. 48 49 Returns 50 ------- 51 iterator: Object 52 Iterator. 53 54 iterator.next(): Function 55 Returns an iterator protocol-compliant object containing the next 56 iterated value (if one exists) and a boolean flag indicating whether the 57 iterator is finished. 58 59 iterator.return( [value] ): Function 60 Finishes an iterator and returns a provided value. 61 62 iterator.seed: Int32Array 63 Pseudorandom number generator seed. 64 65 iterator.seedLength: integer 66 Length of generator seed. 67 68 iterator.state: Int32Array 69 Generator state. 70 71 iterator.stateLength: integer 72 Length of generator state. 73 74 iterator.byteLength: integer 75 Size (in bytes) of generator state. 76 77 Examples 78 -------- 79 > var it = {{alias}}(); 80 > var r = it.next().value 81 <number> 82 > r = it.next().value 83 <number> 84 85 See Also 86 -------- 87