* Inserts a copy of given brick into the pipe. * @param {Brick} brick Pipe brick to be copied * @param {number} index Index at which the copy should be inserted, inserts * the copy after the original brick if omitted * @return {Pipe} Fluent interface
(brick, index = null)
| 229 | * @return {Pipe} Fluent interface |
| 230 | */ |
| 231 | duplicateBrick (brick, index = null) { |
| 232 | if (!this.containsBrick(brick)) { |
| 233 | throw new Error('Brick is not part of the pipe.') |
| 234 | } |
| 235 | if (index === null) { |
| 236 | index = this._bricks.indexOf(brick) |
| 237 | } |
| 238 | this.spliceBricks(index, 0, [brick.copy()]) |
| 239 | return this |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Moves brick to given index. |
no test coverage detected