MCPcopy Create free account
hub / github.com/SAP/ui5-builder / getStringArray

Function getStringArray

lib/lbt/utils/ASTUtils.js:125–139  ·  view source on GitHub ↗
(array, skipNonStringLiterals)

Source from the content-addressed store, hash-verified

123 * @returns {string[]}
124 */
125export 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
141export function getLocation(args) {
142 // NODE-TODO include line information in future

Callers 1

visitFunction · 0.90

Calls 1

getStringValueFunction · 0.85

Tested by

no test coverage detected