* Replaces a single brick. * Convenience method calling Pipe.spliceBricks internally. * @param {Brick} needle Instance to be replaced * @param {Brick|object} replacement Replacement brick instance or * serialized brick object * @throws {Error} If needle is not part of the pipe
(needle, replacement)
| 317 | * @return {Pipe} Fluent interface |
| 318 | */ |
| 319 | replaceBrick (needle, replacement) { |
| 320 | const index = this._bricks.indexOf(needle) |
| 321 | if (index === -1) { |
| 322 | throw new Error('Can\'t replace a brick not being part of the pipe.') |
| 323 | } |
| 324 | this.spliceBricks(index, 1, [replacement]) |
| 325 | return this |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Removes and/or inserts bricks to the pipe at given index maintaining the |
no test coverage detected