From e97644d9d0316df656aed0fd1a7df5854bd96e67 Mon Sep 17 00:00:00 2001 From: Lajos Szoke <63732287+laliconfigcat@users.noreply.github.com> Date: Wed, 1 Jun 2022 11:04:00 +0200 Subject: [PATCH] Browsercompatibility (#52) * polyfills * v5.3.0 --- package-lock.json | 4 ++-- package.json | 2 +- src/Polyfills.ts | 12 ++++++++++++ src/index.ts | 3 +++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/Polyfills.ts diff --git a/package-lock.json b/package-lock.json index 9714c97..1e75084 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "configcat-common", - "version": "5.2.0", + "version": "5.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "configcat-common", - "version": "5.2.0", + "version": "5.3.0", "license": "MIT", "devDependencies": { "@types/chai": "4.3.1", diff --git a/package.json b/package.json index 992513f..d40ef52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "configcat-common", - "version": "5.2.0", + "version": "5.3.0", "description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/Polyfills.ts b/src/Polyfills.ts new file mode 100644 index 0000000..827f303 --- /dev/null +++ b/src/Polyfills.ts @@ -0,0 +1,12 @@ +export function setupPolyfills() { + if (!(Object as any).fromEntries) { + (Object as any).fromEntries = function (entries: any) { + if (!entries || !entries[Symbol.iterator]) { throw new Error('Object.fromEntries() requires a single iterable argument'); } + let obj: any = {}; + for (let [key, value] of entries) { + obj[key] = value; + } + return obj; + }; + } +} diff --git a/src/index.ts b/src/index.ts index 938dfef..8b4619c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,9 @@ import { ConfigCatClient, IConfigCatClient } from "./ConfigCatClient"; import { AutoPollOptions, ManualPollOptions, LazyLoadOptions, IOptions, OptionsBase } from "./ConfigCatClientOptions"; import { ProjectConfig } from "./ProjectConfig"; import { ConfigCatConsoleLogger } from "./ConfigCatLogger"; +import { setupPolyfills } from "./Polyfills"; + +setupPolyfills(); /** * Create an instance of ConfigCatClient and setup AutoPoll mode