* Add a chunk of generated JS to this source node. * * @param aChunk A string snippet of generated JS code, another instance of * SourceNode, or an array where each member is one of those things.
(aChunk)
| 186 | * SourceNode, or an array where each member is one of those things. |
| 187 | */ |
| 188 | add(aChunk) { |
| 189 | if (Array.isArray(aChunk)) { |
| 190 | aChunk.forEach(function (chunk) { |
| 191 | this.add(chunk); |
| 192 | }, this); |
| 193 | } else if (aChunk[isSourceNode] || typeof aChunk === "string") { |
| 194 | if (aChunk) { |
| 195 | this.children.push(aChunk); |
| 196 | } |
| 197 | } else { |
| 198 | throw new TypeError( |
| 199 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + |
| 200 | aChunk |
| 201 | ); |
| 202 | } |
| 203 | return this; |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Add a chunk of generated JS to the beginning of this source node. |
no outgoing calls