From 5e4617ac5548b99f071764a39de927da64a8d380 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 25 Mar 2023 10:50:39 -0400 Subject: [PATCH] *add new helper maybeGetAsyncProperty to process the kernel client proxies if needed --- src/util.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/util.ts b/src/util.ts index 77032b3..fa2a681 100644 --- a/src/util.ts +++ b/src/util.ts @@ -125,3 +125,15 @@ export function setupStream(stream: any) { return stream[RPC_PROTOCOL_SYMBOL]; } + +export async function maybeGetAsyncProperty(object: any) { + if (typeof object === "function") { + object = object(); + } + + if (isPromise(object)) { + object = await object; + } + + return object; +}