MCPcopy
hub / github.com/webpack/webpack / parseString

Method parseString

lib/javascript/JavascriptParser.js:4864–4880  ·  view source on GitHub ↗

* Returns parsed string. * @param {Expression} expression expression * @returns {string} parsed string

(expression)

Source from the content-addressed store, hash-verified

4862 * @returns {string} parsed string
4863 */
4864 parseString(expression) {
4865 switch (expression.type) {
4866 case "BinaryExpression":
4867 if (expression.operator === "+") {
4868 return (
4869 this.parseString(/** @type {Expression} */ (expression.left)) +
4870 this.parseString(expression.right)
4871 );
4872 }
4873 break;
4874 case "Literal":
4875 return String(expression.value);
4876 }
4877 throw new Error(
4878 `${expression.type} is not supported as parameter for require`
4879 );
4880 }
4881
4882 /** @typedef {{ range?: Range, value: string, code: boolean, conditional: false | CalculatedStringResult[] }} CalculatedStringResult */
4883

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected