digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

WIP: Framing #365

Closed gkellogg closed 4 years ago

gkellogg commented 4 years ago
gkellogg commented 4 years ago

This gets much of framing complete. More to do, but I may have a gap in working on it, so this can be reviewed and hopefully merged). This leaves nine failing tests.

Some tests are failing with Node6, which perhaps someone with more experience in the differences can see what might be going on.

gkellogg commented 4 years ago

It looks like the Node 6 failure is due to Object.entries not being defined. There is a suggestion for a PolyFill on the MDN entry for Object.entries.

if (!Object.entries) {
  Object.entries = function( obj ){
    var ownProps = Object.keys( obj ),
        i = ownProps.length,
        resArray = new Array(i); // preallocate the Array
    while (i--)
      resArray[i] = [ownProps[i], obj[ownProps[i]]];

    return resArray;
  };
}

Where would be the best place to apply this?

davidlehn commented 4 years ago

Short answer is to hack it to work for now. core-js for Object.entries, and a shim for Object.fromEntries. I'll try adding it. Was trying to avoid this nonsense in jsonld.js 2.x. Once 1.1 support is mostly or all done I think we'll get radical with changes for a 3.x release. That'll include updating to core-js 3, which has Object.fromEntries, and just dropping node6 support and see if anyone notices.

davidlehn commented 4 years ago

@dlongley Re linting, we do have eslint config here, and a "lint" command, but our rules didn't check for 'brace-style'. Added a PR to consider for that: https://github.com/digitalbazaar/eslint-config-digitalbazaar/pull/31