MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / addNameToOptions

Function addNameToOptions

packages/main/src/babel/babel.ts:29–64  ·  view source on GitHub ↗
(
    node:    t.CallExpression,
    arg_idx: number,
    name:    string,
)

Source from the content-addressed store, hash-verified

27}
28
29function addNameToOptions(
30 node: t.CallExpression,
31 arg_idx: number,
32 name: string,
33): void {
34
35 let name_property = t.objectProperty(NAME_ID, t.stringLiteral(name))
36
37 // fill in-between arguments with undefined
38 while (node.arguments.length < arg_idx) {
39 node.arguments.push(UNDEFINED_ID)
40 }
41
42 // no options argument
43 if (node.arguments.length === arg_idx) {
44 node.arguments.push(t.objectExpression([name_property]))
45 }
46 else {
47 // existing options argument
48 const options = node.arguments[arg_idx]!
49 if (options.type !== 'ObjectExpression') {
50 return
51 }
52
53 // Check there isn't already a "name" property
54 if (options.properties.some(prop =>
55 prop.type === 'ObjectProperty' &&
56 prop.key.type === 'Identifier' &&
57 prop.key.name === NAME_ID.name,
58 )) {
59 return
60 }
61
62 options.properties.unshift(name_property)
63 }
64}
65
66type Source =
67 | 'createSignal'

Callers 2

VariableDeclarationFunction · 0.85
CallExpressionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…