hypercore 10.0.0-alpha.23 → 10.0.0-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,46 +0,0 @@
1
- module.exports = class RandomIterator {
2
- constructor (values) {
3
- this._values = values
4
- this._next = { value: null, done: false }
5
- this._start = 0
6
- this._end = values.length
7
- }
8
-
9
- next () {
10
- if (this._start < this._values.length) {
11
- if (this._start === this._end) this._end = this._values.length
12
-
13
- const r = this._start + (Math.random() * (this._end - this._start)) | 0
14
- const tmp = this._values[r]
15
-
16
- this._values[r] = this._values[this._start]
17
- this._next.value = this._values[this._start++] = tmp
18
- } else {
19
- this._next.done = true
20
- }
21
-
22
- return this._next
23
- }
24
-
25
- reset () {
26
- this._start = 0
27
- this._end = this._values.length
28
- this._next.done = false
29
- return this
30
- }
31
-
32
- requeue () {
33
- if (this._start === this._end) {
34
- this._start--
35
- } else {
36
- const top = this._values[--this._end]
37
-
38
- this._values[this._end] = this._values[--this._start]
39
- this._values[this._start] = top
40
- }
41
- }
42
-
43
- [Symbol.iterator] () {
44
- return this
45
- }
46
- }