MCPcopy Create free account
hub / github.com/prettier/prettier / wrapExpression

Function wrapExpression

src/language-js/parse/utilities/wrap-expression.js:14–36  ·  view source on GitHub ↗

* @param {{ * text: string, * expression?: Node, * type?: string, * rootMarker?: string, * comments?: Comment[], * }} options

(options)

Source from the content-addressed store, hash-verified

12 * }} options
13 */
14function wrapExpression(options) {
15 const {
16 type = "JsExpressionRoot",
17 expression,
18 comments = expression?.comments ?? [],
19 text,
20 rootMarker,
21 } = options;
22
23 const root = {
24 type,
25 comments,
26 range: [0, text.length],
27 rootMarker,
28 };
29
30 if (expression) {
31 delete expression.comments;
32 root.node = expression;
33 }
34
35 return root;
36}
37
38export default wrapExpression;

Callers 3

parseJsonFunction · 0.85
parseFunction · 0.85
createParseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected