Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit a62a809

Browse files
IronTonyMattia Panzeri
authored andcommitted
refactor: rewrite fromEntries function
1 parent 0134f65 commit a62a809

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/utils/keycloak.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ import {
1212
formatQuerystringParameters,
1313
} from './url';
1414

15-
const entriesPolyFill = (obj: any) =>
16-
Object.keys(obj).map((key) => [key, obj[key]]);
15+
function fromEntries<T>(
16+
iterable: IterableIterator<[string, T]>
17+
): { [key: string]: T } {
18+
return [...iterable].reduce<{ [key: string]: T }>(
19+
(obj, [key, val]) => ({
20+
...obj,
21+
[key]: val,
22+
}),
23+
{}
24+
);
25+
}
1726

1827
export function getRealmUrl(realm: string, authServerUrl?: string) {
1928
if (typeof authServerUrl === 'undefined') {
@@ -128,7 +137,7 @@ export function parseCallbackParams(
128137

129138
return {
130139
paramsString: formatQuerystringParameters(otherParams),
131-
oauthParams: entriesPolyFill(oAuthParams.entries()),
140+
oauthParams: fromEntries(oAuthParams.entries()),
132141
};
133142
}
134143

0 commit comments

Comments
 (0)