Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stevemao/composition-trace

Impure trace function to see what's going on in a composition
https://github.com/stevemao/composition-trace

composition debug debugger debugging debugging-tool fp functional-programming

Last synced: about 1 month ago
JSON representation

Impure trace function to see what's going on in a composition

Awesome Lists containing this project

README

        

# Problem

```js
var dasherize = compose(join('-'), toLower, split(' '), replace(/\s{2,}/ig, ' '));

dasherize('The world is a vampire');
// TypeError: Cannot read property 'apply' of undefined
```

What arguments is `toLower` called with?
What does `split(' ')` return?

# Let's `trace`

```js
const trace = require('composition-trace');

var dasherize = compose(join('-'), toLower, trace('after split'), split(' '), replace(/\s{2,}/ig, ' '));
// after split [ 'The', 'world', 'is', 'a', 'vampire' ]

dasherize('The world is a vampire');
```

For more details, please see https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch5.html#debugging

# Alternatives

- [treis](https://github.com/raine/treis)
- [`tap`](http://ramdajs.com/docs/#tap)
- [`do`](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/do.md)

# Related

- [inspect-curry](https://github.com/stevemao/inspect-curry)
- [inspect-compose](https://github.com/stevemao/inspect-compose)