Echo JS 0.11.0

<~>

tracker1 1675 days ago. link 1 point
I'm not sure I find the pipe method really any easier to reason with than the pipeline chain.  Also, if you're using babel, you can just enable the pipeline operator.

https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator

The F# inspired version is probably the best option imo...

https://github.com/valtech-nyc/proposal-fsharp-pipelines

    const getData = async url => url |> fetch |> await |> r => r.json()
    const logIt = async p => p |> await |> console.log;

    'http://foo' |> getData |> logIt;
richytong 1673 days ago. link 1 point
It may not be easier, but you could certainly cut out some async handling steps with rubico pipe

    const getData = pipe(fetch, r => r.json());
    const logIt = console.log;

I really like that last bit though, fsharp pipelines ftw

    'http://foo' |> getData |> logIt;
richytong 1676 days ago. link 1 point
rubico resolves on two promises:

1. simplify asynchronous programming in JavaScript
2. enable functional programming in JavaScript

example request
```javascript
// promise chains
fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(res => res.json())
  .then(console.log) // > {...}

// async/await
void (async () => {
  const res = await fetch('https://jsonplaceholder.typicode.com/todos/1')
  const data = await res.json()
  console.log(data) // > {...}
})()

// rubico
import { pipe } from 'rubico.js'

pipe([
  fetch,
  res => res.json(),
  console.log, // > {...}
])('https://jsonplaceholder.typicode.com/todos/1')
```