aurelia / polyfills

The minimal set of polyfills needed to run Aurelia.
MIT License
26 stars 27 forks source link

Object.entries polyfill #63

Closed zewa666 closed 6 years ago

zewa666 commented 6 years ago

With ES2017 there is Object.entries which is not yet covered by aurelia polyfills. It would be great if we could add that as well.

I'm just not certain where to add this, since there are no ES2017 polyfills prepared yet if I'm not wrong.

Polyfill: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill

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;
  };
EisenbergEffect commented 6 years ago

You could add it here: https://github.com/aurelia/polyfills/blob/master/src/object.js

zewa666 commented 6 years ago

Closed due to discussion in linked PR