Skip to content

brekk/xtrace

Repository files navigation

xtrace

a tool for adding clarity to your compositional-pipelines or just invoking side-effects in a clean way

Originally inspired by this book, this is a more fully-fledged solution for adding simple side-effects to a given operation.

API

Table of Contents

sideEffect

Pass a value to a side effect function but return the original value

Parameters

Examples

import {sideEffect} from 'xtrace'
import {pipe} from 'f-utility'
const multiplyByTwo = x => x * 2
const eventLog => { / * something async * / }
const multiplyByTwoAndNotify = pipe(
  multiplyByTwo
  sideEffect(eventLog)
)

Returns any a

taggedSideEffect

Pass a value and a tag to a side effect function but return the value

Parameters

  • fn Function a function
  • a any anything
  • b any anything

Returns any b

trace

Log a value and a tag but return the value

Parameters

  • fn Function a function
  • a any something to log
  • b any some value

Returns any b

scopedSideEffect

Pass a transformed value and a tag but return the value

Parameters

  • fn Function a function
  • fn2 Function a transformer function
  • a any anything
  • b any anything

Returns any b

scopedTrace

Log a transformed value and a tag but return the value

Parameters

  • fn Function a transformer function
  • a any anything
  • b any anything

Returns any b

About

a tool for adding clarity to your compositional-pipelines

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published