• Re: Adding core-js (ES5+) polyfills

    From Tracker1@VERT/TRN to Tracker1 on Thu Nov 5 10:59:25 2020
    On 10/29/2020 8:41 PM, Tracker1 wrote:
    In the course of working with a few scripts, I've noticed many Js
    language features I've come to rely on tend to be missing.

    For example: Object.(entries|keys|values) and
    Array.protype.(find|filter) etc.

    The core-js polyfill library does seem to load without any issues into
    the platform. How would everyone feel about including it so that it can
    be available to everyone closer to in the box?

    Where to download the built+minified version https://cdnjs.com/libraries/core-js

    The source library.
    https://github.com/zloirock/core-js

    Note: this is pretty much the core of babel support for legacy browsers, it's been pretty useful in Synchronet as well. It does include some polyfills for ES5 that are already built in, but since some behaviors
    change slightly with ES6 it's best to include them all in practice, shouldn't be anything that anyone notices though.

    For example, instead of something like...

    var newsgroups = hdr.newsgroups.split(',');
    for(n in newsgroups)
    for(g in msg_area.grp_list)
    for(s in msg_area.grp_list[g].sub_list)
    if (
    msg_area.grp_list[g].sub_list[s].newsgroup.toLowerCase()
    == newsgroups[n].toLowerCase()
    ) {
    ... msg_area.grp_list[g].sub_list[s] ...
    }

    You could do...

    var newsgroups = hdr.newsgroups.split(',');
    Object.values(msg_area.sub)
    .filter(function(sub) {
    return newsgroups.includes(sub.newsgroup.toLowerCase());
    })
    .foreach(function(sub) {
    ... sub ...
    });

    Of course an updated spidermonkey would allow this to be...

    var newsgroups = hdr.newsgroups.split(',');
    Object.values(msg_area.sub)
    .filter(sub => newsgroups.includes(sub.newsgroup.toLowerCase())
    .foreach(sub => {
    ... sub ...
    });



    --
    Michael J. Ryan
    tracker1 +o Roughneck BBS
    ---
    ­ Synchronet ­ Roughneck BBS - roughneckbbs.com