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

Class Particle

external/.scrollLibs.js:15250–17872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15248 }
15249}
15250class Particle extends AbstractParticle {
15251 constructor(subparticles, line, parent, index) {
15252 super()
15253 // BEGIN MUTABLE METHODS BELOw
15254 this._particleCreationTime = this._getProcessTimeInMilliseconds()
15255 this._parent = parent
15256 this._setLine(line)
15257 this._setSubparticles(subparticles)
15258 if (index !== undefined) parent._getSubparticlesArray().splice(index, 0, this)
15259 else if (parent) parent._getSubparticlesArray().push(this)
15260 }
15261 wake() {}
15262 execute() {}
15263 // If you want to link a particle to a file on the filesystem.
15264 setFile(file) {
15265 this.file = file
15266 }
15267 // todo: perhaps if needed in the future we can add more contextual params here
15268 _transformBlock(block) {
15269 this.particleTransformers.forEach(fn => {
15270 block = fn(block)
15271 })
15272 return block
15273 }
15274 addTransformer(fn) {
15275 if (!this.particleTransformers) this.particleTransformers = []
15276 this.particleTransformers.push(fn)
15277 return this
15278 }
15279 async loadRequirements(context) {
15280 // todo: remove
15281 await Promise.all(this.map(particle => particle.loadRequirements(context)))
15282 }
15283 getErrors() {
15284 return []
15285 }
15286 get lineAtomTypes() {
15287 // todo: make this any a constant
15288 return "undefinedAtomType ".repeat(this.atoms.length).trim()
15289 }
15290 isNodeJs() {
15291 return typeof exports !== "undefined"
15292 }
15293 isBrowser() {
15294 return !this.isNodeJs()
15295 }
15296 getOlderSiblings() {
15297 if (this.isRoot()) return []
15298 return this.parent.slice(0, this.index)
15299 }
15300 _getClosestOlderSibling() {
15301 const olderSiblings = this.getOlderSiblings()
15302 return olderSiblings[olderSiblings.length - 1]
15303 }
15304 getYoungerSiblings() {
15305 if (this.isRoot()) return []
15306 return this.parent.slice(this.index + 1)
15307 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected