(cue, content, circularCheckArray)
| 16572 | } |
| 16573 | // todo: refactor the below. |
| 16574 | _appendFromJavascriptObjectTuple(cue, content, circularCheckArray) { |
| 16575 | const type = typeof content |
| 16576 | let line |
| 16577 | let subparticles |
| 16578 | if (content === null) line = cue + " " + null |
| 16579 | else if (content === undefined) line = cue |
| 16580 | else if (type === "string") { |
| 16581 | const tuple = this._textToContentAndSubparticlesTuple(content) |
| 16582 | line = cue + " " + tuple[0] |
| 16583 | subparticles = tuple[1] |
| 16584 | } else if (type === "function") line = cue + " " + content.toString() |
| 16585 | else if (type !== "object") line = cue + " " + content |
| 16586 | else if (content instanceof Date) line = cue + " " + content.getTime().toString() |
| 16587 | else if (content instanceof Particle) { |
| 16588 | line = cue |
| 16589 | subparticles = new Particle(content.subparticlesToString(), content.getLine()) |
| 16590 | } else if (circularCheckArray.indexOf(content) === -1) { |
| 16591 | circularCheckArray.push(content) |
| 16592 | line = cue |
| 16593 | const length = content instanceof Array ? content.length : Object.keys(content).length |
| 16594 | if (length) subparticles = new Particle()._setSubparticles(content, circularCheckArray) |
| 16595 | } else { |
| 16596 | // iirc this is return early from circular |
| 16597 | return |
| 16598 | } |
| 16599 | this._insertBlock(this._makeBlock(line, subparticles)) |
| 16600 | } |
| 16601 | _insertBlock(block, index) { |
| 16602 | if (index !== undefined) index = index < 0 ? this.length + index : index |
| 16603 | const newParticle = this._getParserPool().createParticle(this, block, index) |
no test coverage detected