Skip to content

Commit

Permalink
Browsercompatibility (#52)
Browse files Browse the repository at this point in the history
* polyfills

* v5.3.0
  • Loading branch information
laliconfigcat authored Jun 1, 2022
1 parent 9bbfaf7 commit e97644d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/Polyfills.ts
Original file line number Diff line number Diff line change
@@ -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;
};
}
}
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e97644d

Please sign in to comment.