diff --git a/ts/src/index.ts b/ts/src/index.ts index b35112e..1ec435b 100644 --- a/ts/src/index.ts +++ b/ts/src/index.ts @@ -1,3 +1,5 @@ +import './polyfills/objectEntries'; + export class Enumify { //#################### Static diff --git a/ts/src/polyfills/objectEntries.ts b/ts/src/polyfills/objectEntries.ts new file mode 100644 index 0000000..38a4d79 --- /dev/null +++ b/ts/src/polyfills/objectEntries.ts @@ -0,0 +1,16 @@ +/* + * Object.entries() polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries + */ +if (!Object.entries) { + Object.entries = function(obj: any) { + const ownProps = Object.keys(obj); + let i = ownProps.length; + let resArray = new Array(i); + while (i--) { + resArray[i] = [ownProps[i], obj[ownProps[i]]]; + } + + return resArray; + }; +} \ No newline at end of file