MCPcopy
hub / github.com/clientIO/joint / parsePathToBinding

Function parsePathToBinding

packages/joint-decorators/src/parser.ts:159–185  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

157}
158
159function parsePathToBinding(path: string): [string[], PathToBinding] {
160 if (fnRegex.test(path)) {
161 const [, name, triggersMatch, ...rawArgs] = path.match(fnRegex);
162
163 const triggersString = (triggersMatch.startsWith('['))
164 ? triggersMatch.substring(1, triggersMatch.length - 1)
165 : triggersMatch;
166
167 const triggers = triggersString.split(',').map(trigger => trigger.trim());
168 // eslint-disable-next-line @typescript-eslint/no-explicit-any
169 const args: any[] = [];
170
171 if (rawArgs[0] !== undefined) {
172 rawArgs.forEach(arg => {
173 try {
174 args.push(JSON.parse(arg));
175 } catch (e) {
176 throw new Error(`Invalid argument ${arg} in function call.`);
177 }
178 });
179 }
180
181 return [triggers, { name, isFunction: true, args }];
182 }
183
184 return [[path], { name: path, isFunction: false, args: [] }];
185}

Callers 1

parseExpressionFunction · 0.85

Calls 2

mapMethod · 0.80
testMethod · 0.45

Tested by

no test coverage detected