(particleOrStr)
| 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 | } |
no test coverage detected