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

Method replaceBrick

src/Pipe.js:319–326  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 2

Pipe.jsFile · 0.80

Calls 2

spliceBricksMethod · 0.95
indexOfMethod · 0.80

Tested by

no test coverage detected