Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Latest commit

 

History

History
62 lines (44 loc) · 1.17 KB

README.md

File metadata and controls

62 lines (44 loc) · 1.17 KB

trace

Build Status

tap function to log a value with optional tag

Install

npm install @strong-roots-capital/trace

Use

import { trace } from "@strong-roots-capital/trace";

import Debug from "debug";
import * as O from "fp-ts/Option";
import { pipe } from "fp-ts/function";

const debug = Debug("defaults");

// If user has specified concurrency, will print on the debug stream:
// "concurrency 4"
const concurrency = pipe(
  O.fromNullable(getUserConcurrency()),
  O.pipe(trace(debug, "concurrency")),
  O.getOrElse(() => 1)
);

Note: also works with console.{info,log,warn,error}

API

trace

trace: (logger: typeof console.log, ...tag: unknown[]) =>
  <T>(value: T) =>
    T;

unsafeTraceJson

trace: (logger: typeof console.log, ...tag: unknown[]) =>
  <T>(value: T) =>
    T;

IOtrace

trace: (logger: typeof console.log, ...tag: unknown[]) =>
  <T>(value: T) =>
  () =>
    T;