(array, skipNonStringLiterals)
| 123 | * @returns {string[]} |
| 124 | */ |
| 125 | export function getStringArray(array, skipNonStringLiterals) { |
| 126 | return array.elements.reduce( (result, item) => { |
| 127 | const value = getStringValue(item); |
| 128 | if ( value !== undefined ) { |
| 129 | result.push(value); |
| 130 | } else if ( !skipNonStringLiterals ) { |
| 131 | if (item.type === Syntax.TemplateLiteral) { |
| 132 | throw new TypeError("array element is a template literal with expressions"); |
| 133 | } else { |
| 134 | throw new TypeError("array element is not a string literal: " + item.type); |
| 135 | } |
| 136 | } |
| 137 | return result; |
| 138 | }, []); |
| 139 | } |
| 140 | |
| 141 | export function getLocation(args) { |
| 142 | // NODE-TODO include line information in future |
no test coverage detected