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

Method duplicateBrick

src/Pipe.js:231–240  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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.

Callers 2

viewBrickDidDropMethod · 0.95
viewMenuItemDidClickMethod · 0.80

Calls 4

containsBrickMethod · 0.95
spliceBricksMethod · 0.95
indexOfMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected