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