import type { Callable, IMetric, ITraceableMapper, ITraceableTuple, MetricsTraceSupplier, } from "@emprespresso/pengueno"; export class TraceUtil { static withTrace( trace: string, ): ITraceableMapper>, Trace> { return (t) => [t.get(), `[${trace}]`]; } static withMetricTrace( metric: IMetric, ): ITraceableMapper>, Trace> { return (t) => [t.get(), metric as Trace]; } static withFunctionTrace( f: F, ): ITraceableMapper>, Trace> { return TraceUtil.withTrace(f.name); } static withClassTrace( c: C, ): ITraceableMapper>, Trace> { return TraceUtil.withTrace(c.constructor.name); } static promiseify( mapper: ITraceableMapper, ): ITraceableMapper, Promise, Trace> { return (traceablePromise) => traceablePromise .flatMapAsync(async (t) => t.move(await t.get()).map(mapper)) .get(); } }