From fec517d06ca02b760093a4da67d8f9c576fffe58 Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Sat, 11 Aug 2018 15:29:08 +0200 Subject: [PATCH] Add Object.entries polyfill --- packages/apollo-server-env/src/index.ts | 1 + packages/apollo-server-env/src/polyfills/Object.entries.ts | 5 +++++ packages/apollo-server-env/src/polyfills/Object.values.ts | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 packages/apollo-server-env/src/polyfills/Object.entries.ts diff --git a/packages/apollo-server-env/src/index.ts b/packages/apollo-server-env/src/index.ts index eba786b314b..eb5864bcd0b 100644 --- a/packages/apollo-server-env/src/index.ts +++ b/packages/apollo-server-env/src/index.ts @@ -1,4 +1,5 @@ import './polyfills/Object.values'; +import './polyfills/Object.entries'; require('util.promisify').shim(); diff --git a/packages/apollo-server-env/src/polyfills/Object.entries.ts b/packages/apollo-server-env/src/polyfills/Object.entries.ts new file mode 100644 index 00000000000..a3779b884ce --- /dev/null +++ b/packages/apollo-server-env/src/polyfills/Object.entries.ts @@ -0,0 +1,5 @@ +if (!global.Object.entries) { + global.Object.entries = function(object: any) { + return Object.keys(object).map(key => [key, object[key]] as [string, any]); + }; +} diff --git a/packages/apollo-server-env/src/polyfills/Object.values.ts b/packages/apollo-server-env/src/polyfills/Object.values.ts index e69754c26f7..65c1fbc7766 100644 --- a/packages/apollo-server-env/src/polyfills/Object.values.ts +++ b/packages/apollo-server-env/src/polyfills/Object.values.ts @@ -1,5 +1,5 @@ if (!global.Object.values) { - global.Object.values = function(o: any) { - return Object.keys(o).map(key => o[key]); + global.Object.values = function(object: any) { + return Object.keys(object).map(key => object[key]); }; }