MCPcopy Create free account
hub / github.com/breck7/scroll / extend

Method extend

external/.scrollLibs.js:16971–16991  ·  view source on GitHub ↗
(particleOrStr)

Source from the content-addressed store, hash-verified

16969 // todo: should take a parsers? to decide whether to overwrite or append.
16970 // todo: this is slow.
16971 extend(particleOrStr) {
16972 const particle = particleOrStr instanceof Particle ? particleOrStr : new Particle(particleOrStr)
16973 const usedCues = new Set()
16974 particle.forEach(sourceParticle => {
16975 const cue = sourceParticle.cue
16976 let targetParticle
16977 const isAnArrayNotMap = usedCues.has(cue)
16978 if (!this.has(cue)) {
16979 usedCues.add(cue)
16980 this.appendLineAndSubparticles(sourceParticle.getLine(), sourceParticle.subparticlesToString())
16981 return true
16982 }
16983 if (isAnArrayNotMap) targetParticle = this.appendLine(sourceParticle.getLine())
16984 else {
16985 targetParticle = this.touchParticle(cue).setContent(sourceParticle.content)
16986 usedCues.add(cue)
16987 }
16988 if (sourceParticle.length) targetParticle.extend(sourceParticle)
16989 })
16990 return this
16991 }
16992 lastParticle() {
16993 return this.getSubparticles()[this.length - 1]
16994 }

Callers 15

.katex.min.jsFile · 0.80
.scrollLibs.jsFile · 0.80
SeFunction · 0.80
LeFunction · 0.80
ltFunction · 0.80
aFunction · 0.80
FtFunction · 0.80
restoreSelectionFunction · 0.80
.leaflet.jsFile · 0.80
IFunction · 0.80
RFunction · 0.80

Calls 9

hasMethod · 0.95
appendLineMethod · 0.95
touchParticleMethod · 0.95
forEachMethod · 0.80
subparticlesToStringMethod · 0.80
setContentMethod · 0.80
addMethod · 0.45
getLineMethod · 0.45

Tested by

no test coverage detected