z-pattern-matching / z

Pattern Matching for Javascript
https://z-pattern-matching.github.io/
Apache License 2.0
1.72k stars 50 forks source link

async/await example #25

Open tkgalk opened 7 years ago

tkgalk commented 7 years ago

Let's say we have this:

matches(x)(
  async (x, xs) => {
    const thing = await somethingElse()
    ...
  },
  (x) => {

  },
)

Will this even...?

paulojean commented 7 years ago

Nop, but you can

matches(42)(
  (x = 42) => {
    return Promise.resolve(44444)
        .then(somethingElse)
        ...
  },
  (x) => {

  }
)

and await outside (eg: from the caller)