invokeFunction argument typecheck
parent
a925212427
commit
e1ac990de9
|
@ -81,6 +81,17 @@ export class System<HookT> extends EventEmitter<SystemEvents<HookT>> {
|
||||||
* @param args an array of arguments to pass to the function
|
* @param args an array of arguments to pass to the function
|
||||||
*/
|
*/
|
||||||
invokeFunction(name: string, args: any[]): Promise<any> {
|
invokeFunction(name: string, args: any[]): Promise<any> {
|
||||||
|
// Some sanity type checks
|
||||||
|
if (typeof name !== "string") {
|
||||||
|
throw new Error(
|
||||||
|
`invokeFunction: function name should be a string, got ${typeof name}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!Array.isArray(args)) {
|
||||||
|
throw new Error(
|
||||||
|
`invokeFunction: args should be an array, got ${typeof args}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
const [plugName, functionName] = name.split(".");
|
const [plugName, functionName] = name.split(".");
|
||||||
if (!functionName) {
|
if (!functionName) {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
|
|
Loading…
Reference in New Issue