import type { Callable } from "@emprespresso/utils"; import { type ITraceableMapper, type ITraceableTuple, TraceableImpl, TraceableLogger, } from "./mod.ts"; export class Traceable extends TraceableImpl { static from(t: T) { return new Traceable(t, new TraceableLogger()); } static withFunctionTrace( f: F, ): ITraceableMapper> { return (t) => [t.item, f.name]; } static withClassTrace( c: C, ): ITraceableMapper> { return (t) => [t.item, c.constructor.name]; } static promiseify( mapper: ITraceableMapper, ): ITraceableMapper, TraceableLogger, Promise> { return (traceablePromise) => traceablePromise.flatMapAsync(async (t) => t.move(await t.item).map(mapper) ).item; } }