diff --git a/src/index.js b/src/index.js index 87be7113c..49aa73b89 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,6 @@ +// Import all polyfills for backward compatibility +import './lib/compatibility/objectEntries'; + import toDate from './lib/toDate'; import toFloat from './lib/toFloat'; import toInt from './lib/toInt'; diff --git a/src/lib/compatibility/objectEntries.js b/src/lib/compatibility/objectEntries.js new file mode 100644 index 000000000..52aed29ca --- /dev/null +++ b/src/lib/compatibility/objectEntries.js @@ -0,0 +1,12 @@ +// For backward compatibility in underlying dependencies +if (!Object.entries) { + Object.entries = function (obj) { + const ownProps = Object.keys(obj); + const resArray = []; + for (let i = 0; i <= ownProps.length; i++) { + resArray.push([ownProps[i], obj[ownProps[i]]]); + } + + return resArray; + }; +}