(this: Printer, node: t.ArrayExpression)
| 115 | } |
| 116 | |
| 117 | export function ArrayExpression(this: Printer, node: t.ArrayExpression) { |
| 118 | const elems = node.elements; |
| 119 | const len = elems.length; |
| 120 | |
| 121 | this.token("["); |
| 122 | |
| 123 | const oldNoLineTerminatorAfterNode = this.enterDelimited(); |
| 124 | |
| 125 | for (let i = 0; i < elems.length; i++) { |
| 126 | const elem = elems[i]; |
| 127 | if (elem) { |
| 128 | if (i > 0) this.space(); |
| 129 | this.print(elem, undefined, true); |
| 130 | if (i < len - 1 || this.shouldPrintTrailingComma("]")) { |
| 131 | this.tokenChar(charCodes.comma, i); |
| 132 | } |
| 133 | } else { |
| 134 | // If the array expression ends with a hole, that hole |
| 135 | // will be ignored by the interpreter, but if it ends with |
| 136 | // two (or more) holes, we need to write out two (or more) |
| 137 | // commas so that the resulting code is interpreted with |
| 138 | // both (all) of the holes. |
| 139 | this.tokenChar(charCodes.comma, i); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode; |
| 144 | |
| 145 | this.token("]"); |
| 146 | } |
| 147 | |
| 148 | export { ArrayExpression as ArrayPattern }; |
| 149 |
nothing calls this directly
no test coverage detected