repl.txt (2863B)
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) whose output is shuffled using the Bays- 11 Durham algorithm. The shuffle step considerably strengthens the "randomness 12 quality" of a simple LCG's output. 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. In 19 general, this generator is unsuitable for Monte Carlo simulations and 20 cryptographic applications. 21 22 Parameters 23 ---------- 24 options: Object (optional) 25 Options. 26 27 options.normalized: boolean (optional) 28 Boolean indicating whether to return pseudorandom numbers on the 29 interval `[0,1)`. 30 31 options.seed: integer|ArrayLikeObject<integer> (optional) 32 Pseudorandom number generator seed. The seed may be either a positive 33 signed 32-bit integer or, for arbitrary length seeds, an array-like 34 object containing positive signed 32-bit integers. 35 36 options.state: Int32Array (optional) 37 Pseudorandom number generator state. If provided, the `seed` option is 38 ignored. 39 40 options.copy: boolean (optional) 41 Boolean indicating whether to copy a provided pseudorandom number 42 generator state. Setting this option to `false` allows sharing state 43 between two or more pseudorandom number generators. Setting this option 44 to `true` ensures that a returned iterator has exclusive control over 45 its internal state. Default: true. 46 47 options.iter: integer (optional) 48 Number of iterations. 49 50 Returns 51 ------- 52 iterator: Object 53 Iterator. 54 55 iterator.next(): Function 56 Returns an iterator protocol-compliant object containing the next 57 iterated value (if one exists) and a boolean flag indicating whether the 58 iterator is finished. 59 60 iterator.return( [value] ): Function 61 Finishes an iterator and returns a provided value. 62 63 iterator.seed: Int32Array 64 Pseudorandom number generator seed. 65 66 iterator.seedLength: integer 67 Length of generator seed. 68 69 iterator.state: Int32Array 70 Generator state. 71 72 iterator.stateLength: integer 73 Length of generator state. 74 75 iterator.byteLength: integer 76 Size (in bytes) of generator state. 77 78 Examples 79 -------- 80 > var it = {{alias}}(); 81 > var r = it.next().value 82 <number> 83 > r = it.next().value 84 <number> 85 86 See Also 87 -------- 88