Skip to content

srghma-backup/ramda-universal-trace

Repository files navigation

Greenkeeper badge Build Status

ramda-universal-trace

Trace function that works fine both in browser and node

In browser it will use

console.log(message, subject)

but in node:

const options = { showHidden: true, depth: 40, colors: true }
console.log(message, util.inspect(subj, options))

Original idea was drawn from this gist

API

traceMeta = R.curryN(4, (logger, modFn, message, obj) => { ... })
traceMod = traceMeta(defaultLogger)
trace = traceMod(R.identity)

check source for more

Usage

import * as R from 'ramda'
import { trace, traceMod } from 'ramda-universal-trace'

const performComplexCalc = R.compose(
    trace('after'),
    R.subtract(__, 2),
    R.divide(__, 4),
    traceMod(R.prop('show_whats_on_this_key'), 'middle'),
    R.multiply(10),
    R.add(10),
    trace('before')
)

Installation

npm i ramda-universal-trace or yarn add ramda-universal-trace

TODO

  • how good this package is optimized with prepack? make 2 versions of this script - one for browser and one for node

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors