MCPcopy Create free account
hub / github.com/chainjet/platform / findOutputKeys

Function findOutputKeys

apps/runner/src/utils/input.utils.ts:186–205  ·  view source on GitHub ↗
(input: Record<string, any>, key: string)

Source from the content-addressed store, hash-verified

184}
185
186export function findOutputKeys(input: Record<string, any>, key: string): string[] {
187 const regex = new RegExp(`{{\\s*${key}\\.(\\w+)\\s*}}`, 'g')
188 const matches: string[] = []
189
190 for (const inputKey in input) {
191 if (typeof input[inputKey] === 'object' && input[inputKey] !== null) {
192 const keys = findOutputKeys(input[inputKey], key)
193 for (const key of keys) {
194 matches.push(key)
195 }
196 } else if (typeof input[inputKey] === 'string') {
197 let match
198 while ((match = regex.exec(input[inputKey])) !== null) {
199 matches.push(match[1])
200 }
201 }
202 }
203
204 return matches
205}
206
207export function strToInterpolationKey(str: string): string {
208 return str.replace(/[^a-zA-Z0-9]/g, '_')

Callers 4

forkMenuMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected