| 79 | } |
| 80 | |
| 81 | class BucketIterator<K, V> implements Iterator<[K, V]> { |
| 82 | constructor(readonly backing: Iterator<NonEmptyArray<readonly [K, V]>>) {} |
| 83 | currentBucket: Iterator<readonly [K, V]> | undefined |
| 84 | next(): IteratorResult<[K, V]> { |
| 85 | if (this.currentBucket === undefined) { |
| 86 | const result = this.backing.next() |
| 87 | if (result.done) { |
| 88 | return result |
| 89 | } |
| 90 | this.currentBucket = result.value[Symbol.iterator]() |
| 91 | } |
| 92 | const result = this.currentBucket.next() |
| 93 | if (result.done) { |
| 94 | this.currentBucket = undefined |
| 95 | return this.next() |
| 96 | } |
| 97 | return result as IteratorResult<[K, V]> |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @since 2.0.0 |
nothing calls this directly
no outgoing calls
no test coverage detected