(
func: ((...args: any[]) => any) | undefined,
obj: {
[p: string]: any;
},
)
| 48 | } |
| 49 | |
| 50 | export function unpackAndCall( |
| 51 | func: ((...args: any[]) => any) | undefined, |
| 52 | obj: { |
| 53 | [p: string]: any; |
| 54 | }, |
| 55 | ): any { |
| 56 | if (!func) return ""; |
| 57 | // Get the names of the function parameters |
| 58 | // @ts-ignore |
| 59 | const paramNames = func |
| 60 | .toString() |
| 61 | .match(/function\s.*?\(([^)]*)\)/)[1] |
| 62 | .split(",") |
| 63 | .map((param) => param.trim()); |
| 64 | |
| 65 | // Sort the object properties according to the function parameters |
| 66 | // @ts-ignore |
| 67 | const args = paramNames.map((paramName) => obj[paramName]); |
| 68 | |
| 69 | // Call the function with the unpacked arguments |
| 70 | // @ts-ignore |
| 71 | return func(...args); |
| 72 | } |
| 73 | |
| 74 | export function stripTrailingAndCurly(str: string) { |
| 75 | // Remove trailing slashes |
nothing calls this directly
no outgoing calls
no test coverage detected