* Call String.prototype.replace on the very right-most source snippet. Useful * for trimming whitespace from the end of a source node, etc. * * @param aPattern The pattern to replace. * @param aReplacement The thing to replace the pattern with.
(aPattern, aReplacement)
| 279 | * @param aReplacement The thing to replace the pattern with. |
| 280 | */ |
| 281 | replaceRight(aPattern, aReplacement) { |
| 282 | const lastChild = this.children[this.children.length - 1]; |
| 283 | if (lastChild[isSourceNode]) { |
| 284 | lastChild.replaceRight(aPattern, aReplacement); |
| 285 | } else if (typeof lastChild === "string") { |
| 286 | this.children[this.children.length - 1] = lastChild.replace( |
| 287 | aPattern, |
| 288 | aReplacement |
| 289 | ); |
| 290 | } else { |
| 291 | this.children.push("".replace(aPattern, aReplacement)); |
| 292 | } |
| 293 | return this; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Set the source content for a source file. This will be added to the SourceMapGenerator |