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

Method moveBrick

src/Pipe.js:248–259  ·  view source on GitHub ↗

* Moves brick to given index. * @param {Brick} brick Pipe brick to be moved * @param {number} index Index the brick should be moved to * @return {Pipe} Fluent interface

(brick, index)

Source from the content-addressed store, hash-verified

246 * @return {Pipe} Fluent interface
247 */
248 moveBrick (brick, index) {
249 const fromIndex = this._bricks.indexOf(brick)
250 if (fromIndex === -1) {
251 throw new Error('Brick is not part of the pipe.')
252 }
253 if (index > fromIndex) {
254 index--
255 }
256 this.spliceBricks(fromIndex, 1)
257 this.spliceBricks(index, 0, [brick])
258 return this
259 }
260
261 /**
262 * Removes single brick from the pipe.

Callers 1

viewBrickDidDropMethod · 0.95

Calls 2

spliceBricksMethod · 0.95
indexOfMethod · 0.80

Tested by

no test coverage detected