(callee, ...args)
| 115 | * @returns {ESTree.CallExpression} |
| 116 | */ |
| 117 | export function call(callee, ...args) { |
| 118 | if (typeof callee === 'string') callee = id(callee); |
| 119 | args = args.slice(); |
| 120 | |
| 121 | // replacing missing arguments with `void(0)`, unless they're at the end in which case remove them |
| 122 | let i = args.length; |
| 123 | let popping = true; |
| 124 | while (i--) { |
| 125 | if (!args[i]) { |
| 126 | if (popping) { |
| 127 | args.pop(); |
| 128 | } else { |
| 129 | args[i] = void0; |
| 130 | } |
| 131 | } else { |
| 132 | popping = false; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return { |
| 137 | type: 'CallExpression', |
| 138 | callee, |
| 139 | arguments: /** @type {Array<ESTree.Expression | ESTree.SpreadElement>} */ (args), |
| 140 | optional: false |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * @param {string | ESTree.Expression} callee |
no test coverage detected