MCPcopy Create free account
hub / github.com/abaplint/transpiler / isAsyncFunction

Function isAsyncFunction

packages/runtime/src/trace.ts:5–17  ·  view source on GitHub ↗
(fn: unknown)

Source from the content-addressed store, hash-verified

3// Polyfill for detecting async functions without relying on Node's "util/types"
4// Works in Node and browser builds.
5const isAsyncFunction = (fn: unknown): fn is (...args: any[]) => Promise<any> => {
6 if (typeof fn !== "function") {
7 return false;
8 }
9 // Reliable brand check
10 const tag = Object.prototype.toString.call(fn);
11 if (tag === "[object AsyncFunction]") {
12 return true;
13 }
14 // Fallback via constructor name (covers most environments)
15 const ctorName = (fn as any)?.constructor?.name;
16 return ctorName === "AsyncFunction";
17};
18
19export class Trace {
20 private readonly traceTotals: {[name: string]: {calls: number, totalRuntime: number}} = {};

Callers 1

setTraceMethod · 0.85

Calls 1

callMethod · 0.65

Tested by

no test coverage detected