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 imported = exported<?.default;
```

Semantically speaking, not only `<?` actually looks like a mice, it also
points at its previous value in case the chaining didn't work.

Beside the basic example, the "mice operator" might save CPU cycles when it
comes to involving more complex expressions, i.e.

```js
// current "solution"
const thing = require('thing')?.default ?? require('thing');

// mice operator
const thing = require('thing')<?.default;
```

This is also easily tranpilable, so kinda a no-brainer for modern dev tools
to bring in.

TL;DR specially for cases where an accessed property should fallback to its
source, this operator might save both typing and CPU time whenever it's
needed.

What do you think about it?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to