Re: Optional chaining syntax but with the "mice" operator ?

2019-09-05 Thread Andrea Giammarchi
Since somebody asked me already elsewhere about the expected precedence of the operator, this would be my answer: ```js const result = await dbQuery(data) wrote: > absolutely, I'm working with PostgreSQL these days and indeed for any > promise/awaited result this pattern looks like a win, and

Re: Optional chaining syntax but with the "mice" operator ?

2019-09-05 Thread Andrea Giammarchi
absolutely, I'm working with PostgreSQL these days and indeed for any promise/awaited result this pattern looks like a win, and while it's targeting a limitation of the chaining one, it can be used in various other cases where knowing the initial result is more important than just falling back to

Re: Optional chaining syntax but with the "mice" operator ?

2019-09-05 Thread Michael Luder-Rosefield
Another pattern it could be useful in is with, say, nosql dbs where something might be an object or id reference: ``` const fooId = foo wrote: > Another use case that I believe will be common is the following one: > > ```js > // current state of the art > const result = dbQuery(data)?.rows ??

Re: Optional chaining syntax but with the "mice" operator ?

2019-09-05 Thread Andrea Giammarchi
Another use case that I believe will be common is the following one: ```js // current state of the art const result = dbQuery(data)?.rows ?? 'did it just failed or what?'; // VS the "mice operator" const result = dbQuery(data) wrote: > On Thu, Sep 5, 2019 at 2:39 PM Andrea Giammarchi > wrote:

Re: Optional chaining syntax but with the "mice" operator ?

2019-09-05 Thread Tab Atkins Jr.
On Thu, Sep 5, 2019 at 2:39 PM Andrea Giammarchi wrote: > > This is basically a solution to a common problem we have these days, where > modules published in the wild might have a `default` property, to support ESM > logic, or not. > > ```js > // current optional chaining logic > const imported

Optional chaining syntax but with the "mice" operator ?

2019-09-05 Thread Andrea Giammarchi
This is basically a solution to a common problem we have these days, where modules published in the wild might have a `default` property, to support ESM logic, or not. ```js // current optional chaining logic const imported = exported?.default ?? exported; // my "mice operator" proposal const