I need some moment to fully understand this:
const compose = ( ...fns ) => fns.reduce( ( f, g ) => ( ...args ) => f( g( ...args ) ) );
reduce method is trickly: when initialValue is not given, the first element of the array is taken as first argument of reduce’s callback parameter, so f is the first argument, g is the second, (…args) is the formal parameters (passed to the resulting function), at the end of the reduction all …fns are applyied in reverse order (i.e. compose(f,g,h) g is applyed before f, and h is applyed before g, resulting in (…args) => f(g(h(…args)) ).
But once I got it it happen to be really an elegant way to write it:
const $d = $data.mergeMap( compose(Rx.Observable.from, r=>r.split('\n')) );
const $d = $data.mergeMap(r=>Rx.Observable.from(r.split('\n')));
that is less readable