Skip to content

Commit

Permalink
Simplify code by replacing Object.entries with Object.keys (#3406)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Dec 4, 2021
1 parent 947165f commit c145cd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/jsutils/mapValue.ts
Expand Up @@ -10,8 +10,8 @@ export function mapValue<T, V>(
): ObjMap<V> {
const result = Object.create(null);

for (const [key, value] of Object.entries(map)) {
result[key] = fn(value, key);
for (const key of Object.keys(map)) {
result[key] = fn(map[key], key);
}
return result;
}
5 changes: 2 additions & 3 deletions src/utilities/lexicographicSortSchema.ts
Expand Up @@ -166,9 +166,8 @@ function sortObjMap<T, R>(
sortValueFn: (value: T) => R,
): ObjMap<R> {
const sortedMap = Object.create(null);
const sortedEntries = sortBy(Object.entries(map), ([key]) => key);
for (const [key, value] of sortedEntries) {
sortedMap[key] = sortValueFn(value);
for (const key of Object.keys(map).sort(naturalCompare)) {
sortedMap[key] = sortValueFn(map[key]);
}
return sortedMap;
}
Expand Down

0 comments on commit c145cd4

Please sign in to comment.