I don't get why argument "it's easy to implement in user land" is raised.

All Array methods are easy to implement in user land. Including recent
additions like .includes and ES2015 methods.

Promises are easy to implement in user land. Smallest implementation is
less than 1kB AFAIR.

Maps, Sets, WeakSets are trivial to implement in user land if WeakMap is
present. Probably less than 50 lines of code.

Object.values, Object.entries, Object.assign,
Object.getOwnPropertyDescriptors, Object.is, Array.from, Array.of. These
methods were added recently but they can be implemented in user land.

On 11 Oct 2017 2:28 am, "Christopher Thorn" <[email protected]> wrote:

> I agree that catch guards are useful, but they can be implemented in
> userland fairly ergonomically:
>
> ```
> function guard(predicate, callback) {
>   return function guarded(reason) {
>     if (!predicate(reason)) {
>       throw reason;
>     }
>     return callback(reason);
>   };
> }
>
> function instanceOf(constructor, callback) {
>   return guard(reason => reason instanceof constructor, callback);
> }
>
> Promise.resolve('invalid')
>   .then(JSON.parse)
>   .catch(instanceOf(SyntaxError, reason => {
>     // do something to handle the syntax error, or perhaps just silence it
>   }));
> ```
>
> Regards, Chris
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to