MCPcopy Create free account
hub / github.com/cryptii/cryptii / getBucketIndexForBrick

Method getBucketIndexForBrick

src/Pipe.js:732–752  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 5

_triggerViewerViewMethod · 0.95
brickSettingDidChangeMethod · 0.95
extractMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected