* Returns lower bucket index for given brick. * @param {Brick} brick * @throws {Error} Throws an error if brick is not part of pipe. * @return {number}
(brick)
| 730 | * @return {number} |
| 731 | */ |
| 732 | getBucketIndexForBrick (brick) { |
| 733 | // The bucket index is equal to the amount of |
| 734 | // encoder bricks placed before given brick |
| 735 | let foundBrick = false |
| 736 | let encoderCount = 0 |
| 737 | let i = -1 |
| 738 | |
| 739 | while (!foundBrick && ++i < this._bricks.length) { |
| 740 | if (this._bricks[i] === brick) { |
| 741 | foundBrick = true |
| 742 | } else if (this._bricks[i] instanceof Encoder) { |
| 743 | encoderCount++ |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | if (!foundBrick) { |
| 748 | throw new Error( |
| 749 | 'Can\'t find bucket for brick. Brick is not part of Pipe.') |
| 750 | } |
| 751 | return encoderCount |
| 752 | } |
| 753 | |
| 754 | /** |
| 755 | * Returns an object containing the lower and upper encoder as well as the |
no outgoing calls
no test coverage detected